Firstly, please post any code inside
Code Tags, "[ code ]
your code here
[ /code ]"
(without spaces). It makes it easier to
read your code and to
help you. :)
Now on to your code, there are a lot of elements in your code that do not make too much sense, such as:
-why you are storing user input to the location of your command line parameters
cin >> *argv;
?
Or why you are even including command line parameters at all?
-you can not compare a character arrays with the equality operator, you have to use the
strcmp(...)
function.
-if your user enters anything but
"word"
(
if your comparison operation worked, which it does not), then it will cause an
infinite loop.
I will try to help you, but I would
HIGHLY recommend that you complete some
C++ tutorials, before you continue on your project. There are some good ones on this website, you can find them here:
http://www.cplusplus.com/doc/tutorial/
O.k. now on to your code.
Firstly,
you do not need any command line parameters, so you can remove any reference to them:
this code becomes:
int main(int argc, char *argv[])
this:
int main()
I believe this is also the cause of your "
C++ forbids a comparsion between a pointer and an integer".
Next
you will need to store the user input in a variable, you can use a
char
array, but using the
String Class (
#include <string>
), is a better approach. You can find information on the
String Class here:
http://www.cplusplus.com/reference/string/string/ and tutorials on them here:
http://www.cplusplus.com/doc/tutorial/basic_io/
The
String Class contains a comparison function
string::compare
, you can find information on it here:
http://www.cplusplus.com/reference/string/string/compare/
Finally, think about the placing of
cin>>
. Where could you put it, so that an
infinite loop can be avoided? Also think about the
type of loop your using. Is a while loop appropriate or is there another form of iteration that suits your purpose better?
Look over the links I've given you and try again, if you get stuck just post here and I'm sure someone will help you out.
Seriously consider doing some tutorials.
I hope this helps and
good luck!