Illegal operation

This is a discussion on Illegal operation within the C Programming forums, part of the General Programming Boards category; I have written a program which sorts 5 user inputted integers in order within an array. The program is great ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    8

    Illegal operation

    I have written a program which sorts 5 user inputted integers in order within an array. The program is great but the only problem comes when exiting a while loop and I recieve an "Illegal Operation" notification.

    The code for the loop is as follows:

    while (again !='n')
    {

    /* The program itself is here but I don't think it is neccesary to include it all in this post!*/

    printf("\nWould you like to continue? (y/n)");
    scanf("%s", &again);
    }

    I can't see a problem and when y (or any other character) is selected it loops as intended.

    Any ideas anyone?

    Cheers

  2. #2
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    do scanf("%c",&again);

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could use fgetc(). That works just as well (if not better).

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 12-04-2008, 08:15 PM
  2. i get illegal operation.
    By entry_point in forum C++ Programming
    Replies: 4
    Last Post: 10-02-2007, 10:41 PM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 03:53 PM
  4. illegal operation error
    By xlordt in forum C Programming
    Replies: 2
    Last Post: 09-01-2003, 08:53 AM
  5. Illegal Operation
    By Bert in forum C++ Programming
    Replies: 15
    Last Post: 07-22-2002, 11:29 AM

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