illegal operation error

This is a discussion on illegal operation error within the C Programming forums, part of the General Programming Boards category; hmm for some reason this program is causing an illegal operation Code: #include <stdio.h> int main() { char name; printf( ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    227

    illegal operation error

    hmm for some reason this program is causing an illegal operation

    Code:
    #include <stdio.h>
    
    int main()
    {
    
          char name;
    
          printf( "What is your name " );
          scanf( "%s", &name );
          printf( "Welcome %s", &name );
          getch( );
    
          return 0;
    
    }
    BTW.. heh i been here before.. just... got in to some trouble.. and lost all in c now i have to start from squer one
    Last edited by xlordt; 09-01-2003 at 07:42 AM.
    Only the strong survives.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>scanf( "%s", &name );
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    Or I suppose if you really want to use scanf(), use:
    char name[100];
    and
    scanf( "%s", name );
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    227
    ahh yes.. i remember now.. thanx.. i forgot to add that part =)
    Only the strong survives.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. file reading
    By gunghomiller in forum C++ Programming
    Replies: 9
    Last Post: 08-07-2007, 10:55 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21