Prototype Help please !

This is a discussion on Prototype Help please ! within the C Programming forums, part of the General Programming Boards category; Output: User input : "this is a test" Search character: "h" This program will inform the user that the text ...

  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);
    }
    Attached Files Attached Files

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,406
    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,458
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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, 04:27 PM
  3. prototype poblem
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 10-30-2005, 09: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, 11:20 AM

Tags for this Thread


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