Hi,
I have a bit of a problem passing command line stuff to my program in Linux. Here is the program:
[tt]
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char string[100];
//here
sscanf(string, "%s", argv[1]);
printf("Plaintext: %s\n", string);
printf("Plaintext: %s\n", argv[1]);
return 0;
}
[/tt]
If I comment out the two lines after the //here comment, the program runs fine, and prints out the second element of the arguments. If I uncomment the two lines after the //here comment I het junk printed out for *both* of the printf statements! Anyone any ideas why this might be?
Thanks
Will.
will@hellacool.co.uk
I have a bit of a problem passing command line stuff to my program in Linux. Here is the program:
[tt]
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char string[100];
//here
sscanf(string, "%s", argv[1]);
printf("Plaintext: %s\n", string);
printf("Plaintext: %s\n", argv[1]);
return 0;
}
[/tt]
If I comment out the two lines after the //here comment, the program runs fine, and prints out the second element of the arguments. If I uncomment the two lines after the //here comment I het junk printed out for *both* of the printf statements! Anyone any ideas why this might be?
Thanks
Will.
will@hellacool.co.uk