Thread: Desperately Need Help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    55
    Should i use strtol() in my program to turn the input from fgets to integers on the questions where the user is asked to input age?

    is this correct usage of what Salem coded:

    Code:
    #include<stdio.h>
    
    int main(void)
    {
    	char buff[4];
    	int iTestInput;
    
    	do
    	{
    	printf("Please enter your age: ");
    	iTestInput = fgets(buff, sizeof buff, stdin);
    	}while (iTestInput == 0 && fgets(buff, sizeof buff, stdin) != NULL) ;
    
    	if (buff < 18)
    	{
    		printf("young");
    	}
    	else if (buff >= 18)
    	{
    		printf("not young");
    	}
    	
    	return 0;
    }
    Last edited by Astra; 10-21-2006 at 08:36 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic C-- Help Desperately Needed
    By toadkiwi in forum C Programming
    Replies: 10
    Last Post: 02-14-2008, 11:08 PM
  2. Replies: 2
    Last Post: 05-27-2005, 05:05 PM
  3. Color ListBox (Need help desperately pls....)
    By wayne in forum C++ Programming
    Replies: 3
    Last Post: 05-25-2005, 04:02 AM
  4. Student desperately needing help!
    By pinkpanther1586 in forum C Programming
    Replies: 4
    Last Post: 10-26-2003, 08:46 AM
  5. I desperately need a project..........
    By frenchfry164 in forum Game Programming
    Replies: 13
    Last Post: 07-03-2003, 11:45 AM