[C] three questions:
one
Code:
for ( x = 1 ; x < argc ; x++ ) $ ./compiledbinary joe It does not print back 'You said joe'. However, it does print '1 joe' Which means that printf 'can read' argv[x], but it seems == 'can't' compare argv[x] with a static string. If I make a variable called foo and put "joe" (char *foo = "joe";) in it, it _does_ work. :confused: two Code:
char a; three I'd like to write KDE apps with Kdevelop in C. What approach is there? |
one:
the string dont get compared the way you are trying to do ... strings are stored in C as arrays of charaters that are terminated by a NULL ('\0') character... therefore to get what you want do this strcmp(argv,"joe") also add string.h in your header files... for the case of char *foo u are actually comparing two characters which in your case are equal... *foo=argv[x] ... two: again string comparision are not inbuilt into C therefore u cannot switch on them use strcmp library function and if statement... three: just use one of the wizrds and generate a skeleton program then play with it ... u will get the idea ... |
for one:
That's because I don't think you can compare strings with '==' you need to use strcmp (IIRC) |
Thank you! I was wondering about a strcmp function somewhere ...
/* looks at wrist */ 10 minutes sweet reply time! |
/* please never mind */
|
All times are GMT -5. The time now is 10:51 AM. |