<Here's the Code>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int questionNumber;
char question[20];
FILE *cfPtr;
if((cfPtr = fopen("questions.txt","r")) == NULL)
printf("File could not be opened\n");
else {
printf("\n Question 1\n");
printf("________________________________________________________________________\n\n");
fscanf(cfPtr, "%d%s", &questionNumber,question);
if(questionNumber!=0){
printf("%d%s\n\n",questionNumber,question);
fscanf(cfPtr, "%d%s", &questionNumber,question);}
fclose(cfPtr);
}/*end else*/
printf("\npress any key to continue: ");
while(!getchar());
return 0;
}
Edited by WingedPanther, 18 October 2008 - 09:46 AM.
add code tags


Sign In
Create Account


Back to top









