I have written a C program. It compiles and works fine on DevC on Windows 7.
But when I compile it on Linux mint (using 'gcc main.c' command) it does not compile and give errors. These errors are not shown while compiling on Windows 7. So nothing must be wrong on Linux as well! How to compile it on Linux through gcc
?
C Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char command[100];
printf("Enter the command:");
scanf("%[^\t\n]", &command);
printf("%s\n", command);
strchr(command, '&');
printf("%i", strchr(command, '&'));
system("PAUSE");
return 0;
}
Errors:
mint@mint ~ $ gcc ass1/main.c
ass1/main.c: In function 'main':
ass1/main.c:8:5: warning: format '%[^
' expects argument of type 'char *', but argument 2 has type 'char (*)[100]' [-Wformat]
ass1/main.c:11:3: warning: incompatible implicit declaration of built-in function 'strchr' [enabled by default]
ass1/main.c:13:5: warning: format '%i' expects argument of type 'int', but argument 2 has type 'char *' [-Wformat]