Thread: Help with trying to kill repeat function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Student otchster's Avatar
    Join Date
    Oct 2005
    Posts
    30

    Help with trying to kill repeat function

    I'm a bit new to C, and I supposed to code a program that prompts for a character, and then will echo the same character, ascii and hex equiv. of that character. It is supposed to repeat the process, prompting again, and will keep going until the user inputs a ! character. I can't figure out why the ! isant killing the program.

    all help is much appreciated, this is my first post here, and look forward to being an active, responseable member. Thanks!

    my code:

    Code:
    #include <stdio.h>
    #define FLAG '!'
    
    int instruct();
    int getval();
    int displayval();
    int repeat();
    
    int main()
    {
      char car;
      instruct();
      car = getval();
    
      displayval();
      while (car != FLAG)
        {
          repeat();
        }
      return (0);
    }
    
    int instruct()
    {
      printf("Please enter a (character) value: \n");
      return (0);
    }
    
    int getval()
      {
        char car;
        car = getc(stdin);
        fpurge(stdin);
        return (0);
      }
    
    int displayval()
      {
        char car;
        printf("Character: %c\t ascii: %u\t hex: %#X\n", car, car, car);
        return (0);
      }
    
    int repeat()
      {
        instruct();
        getval();
        displayval();
    
        return (0);
      }
    Last edited by otchster; 10-25-2005 at 06:27 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 08:28 AM
  2. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM