Thread: while loop.. do while..?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    60

    Angry while loop.. do while..?

    Hi everyone...
    I'm having trouble with a loop... well, I guess the problem is coming from the loop actually.
    The program is compiling, but it seems like the loop is an endless one, and I don't understand why. Here's the code:

    Code:
    void displayInfo(EMP employee[]) {
      int i=0;
      int k=0;
      char temp[MAXLEN];
    
      puts("Enter employee's last name:");
      scanf("%s", temp);
    
      while (temp != employee[i].last_name)
        i++;
    
      printf("Employee ID: %d\n", employee[i].ID);
      printf("Employee last name: %s\n", employee[i].last_name);
      printf("Employee first name: %s\n", employee[i].first_name);
      printf("Employee department: %s\n", employee[i].dept);
      printf("Employee salary: $%.2f\n", employee[i].salary);
    
      puts("What else do you want to do? ");
      return;
    }
    I'm sure I'm doing something stupid, but it really looks good to me... If you could help me out here...
    Last edited by Lau; 11-11-2002 at 03:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 10:21 PM
  2. While loop misbehaving (or misunderstanding)
    By mattAU in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 02:14 AM
  3. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 12:38 PM
  4. while loop help
    By bliznags in forum C Programming
    Replies: 5
    Last Post: 03-20-2005, 12:30 AM
  5. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 09:14 AM