S
sid
Hi!
I am using gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5) on an Ubuntu 6.06
64bit version on an AMD 64bit machine. Each time I compile and execute
the following program I get segmentation fault. Please tell me whether
the code I have written has some errors or whether there is problem
with my OS or the compiler.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc,char *argv[])
{
int c;
if(argc == 0)
printf("\nNo Arguments\n");
else if(strcmp(argv[argc],"lower") == 0)
{
while((c = getchar()) != EOF)
putchar(tolower(c));
}
else
{
while((c = getchar()) != EOF)
putchar(toupper(c));
}
return 0;
}
I am using gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5) on an Ubuntu 6.06
64bit version on an AMD 64bit machine. Each time I compile and execute
the following program I get segmentation fault. Please tell me whether
the code I have written has some errors or whether there is problem
with my OS or the compiler.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc,char *argv[])
{
int c;
if(argc == 0)
printf("\nNo Arguments\n");
else if(strcmp(argv[argc],"lower") == 0)
{
while((c = getchar()) != EOF)
putchar(tolower(c));
}
else
{
while((c = getchar()) != EOF)
putchar(toupper(c));
}
return 0;
}