Thread: Don' t know what to write in the while loop.

  1. #1
    Registered User
    Join Date
    Jul 2010

    Don' t know what to write in the while loop.

    #include <stdio.h>
    #include <stdlib.h>
    int main(void){
    	FILE* infile;
    	char name[81];
    	int age;
    		printf("Please type your age:\n");
    		scanf("%d", age);
    		printf("Please type your name:\n");
    		scanf("%s", name);
    			printf("File didn' found!");
    		while(fscanf(infile,"%s %d", name, &age)!=EOF){
    	return 0;
    Hi guys...
    i have a file that contains:

    Billys 20

    and i want to print them using the above code but i don' t know what to put insteed of the questionmark. I want to "save" them into the 2 variables but this "job" is already end in the code that i did.

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    This is response to your other mistake thread. If I post there, you won't be able to delete it. If you want to delete your other message, click on the edit button at the bottom, click delete, and then you will see a radio box to confirm you want to delete, then click ok.

  3. #3
    Registered User
    Join Date
    Sep 2006
    If you want to print out the names and ages from the file, you'll want a printf() line of code inside that while loop.

    Take a few minutes and think it through, this isn't difficult stuff to figure out.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    Take a moment to read through Scanf woes - cpwiki, as well.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. open read write close
    By mercuryfrost in forum C Programming
    Replies: 7
    Last Post: 08-23-2009, 05:27 PM
  2. return to start coding?
    By talnoy in forum C++ Programming
    Replies: 1
    Last Post: 01-26-2006, 03:48 AM
  3. loop needed also how to make input use letters
    By LoRdHSV1991 in forum C Programming
    Replies: 3
    Last Post: 01-13-2006, 05:39 AM
  4. Some humour...
    By Stan100 in forum A Brief History of
    Replies: 8
    Last Post: 11-06-2003, 10:25 PM
  5. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM