monkeyboi
08-25-2002, 12:13 AM
i wrote a small factor program (i kno they already have one came with most distro from GNU)
anyway my problem is i can't get my text argument to work here is an example..
#include <stdio.h>
main(int argc, char *argv[])
{
if (argv[1] == "test")
{
printf("working!");
}
else
{
printf("not working!");
}
}
ok i compiled and enter
user$ c test
not working!
user$
y is that?? shouldn't it be working cuz the test is the same...
it works fine for number when i use atoi() function to convert the argv string into integer. but the argv is already char data type....
any1 have any idea how fix this or is there is string converter like atoi() for integer???
thx!
anyway my problem is i can't get my text argument to work here is an example..
#include <stdio.h>
main(int argc, char *argv[])
{
if (argv[1] == "test")
{
printf("working!");
}
else
{
printf("not working!");
}
}
ok i compiled and enter
user$ c test
not working!
user$
y is that?? shouldn't it be working cuz the test is the same...
it works fine for number when i use atoi() function to convert the argv string into integer. but the argv is already char data type....
any1 have any idea how fix this or is there is string converter like atoi() for integer???
thx!