|
method007 wrote: is only possible in visual c++
Why? A .NET application would seem to be a much better choice.
method007 wrote: code did not compile and gave me 16 erros!!
this is exactly what I meant about not having C/C++ basic experience. It could take you months and hundreds of posts to finsish your job using a forum.
method007 wrote: error C2065: 'HINTERNET' : undeclared identifier
That means you have not included a required header file. That is basic C/C++ knowledge. A perfect example of what I am telling you. If you are going to develop using VC++ you better go back to the start and learn some basics, jumping into an actual project when you don't even know about including header files is completely insane.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
i know man i need to learn the basic and i do not know how to defind a header for it !! (
|
|
|
|
|
Buy a book for beginner C++ . Don't do a project until you actually understand everything in the book. Once you understand everything in the beginner C++ book you will have scratched the surface.
Then repeat for Windows Development.
Then repeat for HTTP and HTML ( of course this book may not exist ).
Of course there is the famous book "Learn Visual C++ in 21 days". You could try that one... and if in 21 days you have actually learned Visual C++ "completely" you should donate half your salary for the next 5 years to the author.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
man i have the book Learn Visual C++ in 21 days and i read first few chapters. so u think your solution will allow me get the dynamic html that i need for further process corectly? The reason i want to make sure is that the html that i am after is dynamic and i need to retrive it every one min so i do not want to get the old html for each request.
Furthermor, could u tell me what chapter of that books talkes about retriving html ?
|
|
|
|
|
I must apologize. My comments about that book are pure sarcasm. No one can learn Visual C++ in 21 days. I have no idea what is in the book because the title is so stupid I would never read it or recommend it.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
led i want to thank u i fixed that code it works good! )
|
|
|
|
|
First, I thank those who provided their feedback from earlier post.
I need some tweaking once again
As stated earlier, I have a program that should accept only keyboard input of integers from 1 to 12.
Someone suggested I try the scanf() function. I did something with it as shown below. Currently, it allows all integers as valid input and no other characters (letters, punctuatation, symbols, ect . . .).
This is fine. But, how can I further restrict user input with the scanf() function to allow only integers 1 thru 12? Or should I use another method? This is my first time using scanf. I've already tried the while conditions
while (data >=0 || data <= 13), (data >=0 && data <= 13) with not much luck. At this point I'm not sure if I should change how I'm retrieving the data (thru cin or getline). This is a very pivotable part of the program and the whole program is dependent on this functionality. Help is appreciated.
char buff[1024];
unsigned int value;
int charsRead;
bool validEntry = false;
while (!validEntry)
{
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1)
validEntry = true;
}
-- modified at 11:13 Wednesday 12th July, 2006
|
|
|
|
|
Does this not work:
do
{
cout << "Please ... ";
cin >> value;
} while (value < 1 || value > 12); It's certainly a lot simpler than all of that other stuff (e.g., validentry , sscanf() ).
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I ended up doing this instead:
char buff[1024];
unsigned int value;
int charsRead;
bool validEntry = false;
while (!validEntry)
{
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1)
validEntry = true;
if (validEntry == true)
if (value >= 1 && value <= 12)
break;
else
validEntry =false;
}
It seems to work in main() but I still need to test it in the function I created since that is where I want it. I've had some issues when passing data between functions.
Thanks
-- modified at 11:40 Wednesday 12th July, 2006
|
|
|
|
|
Harold_Wishes wrote: I ended up doing this instead:
And this is acceptable? It sure seems like a bunch of unnecessary code.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Since I've had so many runtime errors with my output, I decided to leave it as is. I've spent too much time on it already. For me, the scanf() seems to work the best although I'm not very familiar with it. If there is a better solution ( as I'm not an experienced programmer) I would appreciate the feedback.
Thanks
-- modified at 12:28 Wednesday 12th July, 2006
I might mention that the code below does not test for non-numeric values which causes my screen output to scroll endlessly with text. I need the input to be an integer because I'm using it as a counter in the rest of my program.
do{
cout << "Please ... ";
cin >> data2;
} while (data2 < 1 || data2 > 12);
-- modified at 12:31 Wednesday 12th July, 2006
|
|
|
|
|
Harold_Wishes wrote: I might mention that the code below does not test for non-numeric values...
True. If that is a requirement, then I would use getchar() instead.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You are doing far too much work for this.
int getInput(int range_min, int range_max)
{
int ret = range_min - 1;
do
{
char buffer[100] = {0};
cout << "Enter a value: ";
cin.getline(buffer, 99, '\n');
ret = atoi(buffer);
if (range_min > ret || ret > range_max)
{
cout << "Invalid entry!" << endl;
}
} while (range_min > ret || ret > range_max);
return ret;
}
int main()
{
int count = getInput(1, 11);
cout << "You entered: " << count << endl;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Harold, what I would do is:
<br />
char buff[1024];<br />
unsigned int value;<br />
int charsRead;<br />
<br />
bool validEntry = false;<br />
while (!validEntry){ <br />
cout << "Please enter the number of subunits: ";<br />
cin.getline(buff, 1023, '\n');<br />
<br />
if (sscanf(buff, "%u%n",&value,&charsRead)==1 && value >=1 && value <= 12)<br />
validEntry = true;<br />
}<br />
Otherwise, if you want to use c++ style stuff (I rarely do because I mostly work with windows programs and text strings), you could do sth like this:
<br />
int test;<br />
std::string dump;<br />
<br />
bool valid = false;<br />
while(!valid) {<br />
cout << "Please enter a number: ";<br />
cin >> test;<br />
<br />
if (!cin.fail())<br />
valid = true;<br />
else {<br />
cin.clear();<br />
cin >> dump;
}<br />
<br />
if (valid && (test < 1 || test > 12)) {<br />
valid = false;<br />
cout << "Out of range" << endl;<br />
}<br />
<br />
}<br />
cout << "You entered " << test << endl;<br />
PS: how does everyone get code to not remove all spacing?
earl
-- modified at 14:53 Wednesday 12th July, 2006
|
|
|
|
|
I think this code below compiles. I only reformatted. I shortened the logic in the program as suggested and it works. The only problem I'm having is duplicate output (something I encountered last week). Below the user is prompted to enter data twice in sequence. The first time the user is prompted to make a selection from a menu screen (no big deal).
But, after the user hits the ENTER key, the user will see duplicates of the second prompt. It is as if the user hit the enter key twice.
How do I prevent this from happening? Better question . . . Why is it happening?
I know the compiler is taking me thru the while loop an extra time which is printing the duplicate prompt (confirmed by the debugger).
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
int main()
{
int data2;
char buff[1024];
unsigned int value;
int charsRead;
char selection;
cout << "A) Complete B) Partial C) UNKNOWN" << endl;
cin >> selection;
bool validEntry = false;
while (!validEntry)
{
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1 && value >=1 && value <= 12)
validEntry = true;
}
data2 = value;
return 0;
}
-- modified at 21:56 Wednesday 12th July, 2006
|
|
|
|
|
I include pthread.h but the compiler produced an error which was ( fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory) why was this error produced?
|
|
|
|
|
pthread is a header you wrote ?
i doubt it exists on visual C++ compiler.
aren't you compiling a source you found on the internet with a wrong compiler ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
toxcct wrote: pthread is a header you wrote
No it's Posix thread library ported to Win32 i think by Cygnus
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
mehmetned wrote: why was this error produced?
Because the preprocessor could not find the file.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You need to make sure the compiler can "see" the files from the library. In the IDE usually under the Tools/Options menu item you can find the VC++ Directory settings. You probably need to add the paths to the library in those settings.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
It's a header file for a POSIX thread library. Where is your code from? POSIX threads have been implemented on Unix, Linux and Windows. Try to figure out what POSIX library yous code was using.
Best,
Jun
|
|
|
|
|
The following doesn't compile:
struct A
{
A* partner;
void doodah()
{ ++partner->value; } //this is legal
protected:
int value;
};
struct B: public A
{
void foobar()
{ partner->value += 2; } //but this isn’t
};
The complaint is that foobar() can't access A::value. But B is an A and A can access the value member of another A. So why can't B - which IS AN A - access the value member of another A?
--Dave Schumann
|
|
|
|
|
i really don't see anything wrong in the code (except the doodah() method is a little dirty, but anyway).
what does the compiler say exactly (code + message) ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
FILENAME.cpp(230) : error C2248: 'A::value' : cannot access protected member declared in class 'A'
FILENAME.cpp(224) : see declaration of 'A::value'
FILENAME.cpp(218) : see declaration of 'A'
line 230 is the "partner->value += 2" call in foobar(). It has no complaint about the "++partner->value" call in doodah().
I'm not a language lawyer but this seems like it should be legal.
|
|
|
|
|
It may be that you are trying to implement class like behaviour using structs.
Try this:
struct A
{
// Let the compiler know that B can access A's protected members.
friend struct B;
A* partner;
void doodah()
{ ++partner->value; } //this is legal
protected:
int value;
};
Dave Kerr
codechamber@hotmail.com
http://www.codechamber.com
|
|
|
|