Thread: Prototype Help please !

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    1

    Post Prototype Help please !

    Output:
    User input : "this is a test"
    Search character: "h"
    This program will inform the user that the text contains 1 h.
    The user will enter EXIT on the command line to terminate program ( while loop "exit" !=0)

    Function require:
    get_user_input() - will func gets() to get command line

    parse_command_line() - will prompt the user for the search character then search the command
    ** This func will call the func display_results()

    Display_results() - display string search.
    -------------------------------------------------------------
    My program was working fine without these prototypes. But it's really confused me when I try to put all the func together. Please help me out. Thank you.

    Code:
    #include "stdafx.h"
    #include "conio.h"
    
    void get_user_input(char[80]);
    void parse_command_line(char[80]);
    int display_results(void);
    int _tmain(int argc, _TCHAR* argv[])
    {
    
    	char userInput[80],search[80];
    int count=0;
    int i=0;
    
    get_user_input(userInput);
    parse_command_line(search);
    display_results();
    
    
    getch();
    
    return 0;
    
    }
    
    void get_user_input(userInput);{
    
    
    printf("User Input \n");
    gets(userInput);
    }
    
    parse_command_line(search){
    printf("\n The search character is \n");
    gets(search);
    
    
    
    for (i=0;i<80;i++)
    		{
       if(userInput[i]==search[0])
       {
    	   count++; 
       }
    		}
    }
    int display_results(void){
    printf("The string contains %d ",count);
    }

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    void get_user_input(userInput);{

    that doesnt look too healthy, and you will find it easier to fix problems if you sort out the messy formatting
    Last edited by rogster001; 04-01-2010 at 07:33 AM.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by tminh90 View Post
    get_user_input() - will func gets() to get command line
    if this is requirement of your tutor - you need to find another one...

    Read FAQ why gets should not be used
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 08-24-2006, 12:22 AM
  2. Function prototype questions
    By Kayoss in forum C++ Programming
    Replies: 6
    Last Post: 11-30-2005, 05:27 PM
  3. prototype poblem
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 10-30-2005, 10:01 AM
  4. Prototype syntax for sub-class constructor
    By starkhorn in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2004, 07:33 AM
  5. call to function without prototype
    By lgbeeb in forum C Programming
    Replies: 2
    Last Post: 03-25-2003, 12:20 PM

Tags for this Thread