Error compiling C program in gcc

Asked by sidra

Sir I have written following program in gcc i m getting errors while compiling it.need help....!

#include<stdio.h>
#include<string.h>

int check_authentication(char *password)
  {
    int auth_flag = 0;
    char password_buffer[16];
    strcpy(password_buffer, password);
    if(strcmp(password_buffer, "seecs") == 0)
       auth_flag = 1;
    return auth_flag;
  }
int main (int argc,char *argv[])

 {
    if(check_authentication(argv[1]))
       printf("Access Granted\n");
    else
       printf("\nAccess Denied\n");
return 1;
 }

**********Error Message**********

asif@asif-desktop:~$ gcc -g test.c -o test
test.c: In function ‘check_authentication’:
test.c:6: error: stray ‘\302’ in program
test.c:6: error: stray ‘\240’ in program
test.c:6: error: stray ‘\302’ in program
test.c:6: error: stray ‘\240’ in program
test.c:8: error: stray ‘\302’ in program
test.c:8: error: stray ‘\240’ in program
test.c:9: error: stray ‘\302’ in program
test.c:9: error: stray ‘\240’ in program
test.c:10: error: stray ‘\302’ in program
test.c:10: error: stray ‘\240’ in program
test.c:11: error: stray ‘\302’ in program
test.c:11: error: stray ‘\240’ in program
test.c: In function ‘main’:
test.c:16: error: stray ‘\302’ in program
test.c:16: error: stray ‘\240’ in program
test.c:18: error: stray ‘\302’ in program
test.c:18: error: stray ‘\240’ in program

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gcc-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
sidra
Solved:
Last query:
Last reply:
Revision history for this message
adsadasda (asdsadasdsa-deactivatedaccount) said :
#1

you receive these errors when you compile it or when you run it?i compiled your program and it works fine to me.

Revision history for this message
Hemanth (hemanth-hm) said :
#2

File is from a Windows box , is it?

Try :

$ sudo apt-get install tofrodos

$ dos2unix test.c

$ ggc -g test.c -o test

Revision history for this message
sidra (sidrakhan154) said :
#3

I m getting error in compiling my program with gcc.i installed the tofrodos package.

sudo apt-get install tofrodos

dos2unix test.c

but the
$ ggc -g test.c -o test

this statment does not work....

bash: ggc: command not found

which packages i need to install my program with gdb?????? actualy i m quite new in linux.using ubuntu.

Revision history for this message
sidra (sidrakhan154) said :
#4

file is not from any windows box.i have to analyze this program for buffer overflow vulnerability with GDB and linux.

Revision history for this message
Ankur Banerjee (ankurb) said :
#5

The last command from Hemanth had 'gcc' misspelled as 'ggc'. Use gcc instead and it should work.

Revision history for this message
sidra (sidrakhan154) said :
#6

 thanku very much for ur assistance.i observed the program with emacs.some hidden chahracters were present in my program thats why it was not compiling correctly.now its fine.