Home › Forums › C Programming › C- help with Clear screen
- This topic has 4 replies, 2 voices, and was last updated 15 years, 11 months ago by RandolpNolen.
- AuthorPosts
- October 20, 2008 at 11:55 pm #2145RandolpNolenParticipant
hey guys
Heres my code>>>>
12345<br /><br />kkk<br /><br /> - October 21, 2008 at 8:25 pm #3464GWILouisaxwzklaParticipant
What I might do is put a marker in between each question in the file so that one can be read at a time , like:
A for loop is designed to
a.)run only if the condition is false
b.)run a set number of times
c.)run at least once
d.)run when there are no conditions@
A while loop is designed to
a.)run only if the condition is true
b.) run a set number of times
c.)run at least once
d.)run when there are no conditionsso that you can read up to the ‘@’ character , stop and get the answer and then continue. You could make the while loop read one word at a time ( stopping when you read ‘@’ ) and then get the answer.
- October 21, 2008 at 11:43 pm #3465RandolpNolenParticipant
@dman wrote:
What I might do is put a marker in between each question in the file so that one can be read at a time , like:
A for loop is designed to
a.)run only if the condition is false
b.)run a set number of times
c.)run at least once
d.)run when there are no conditions@
A while loop is designed to
a.)run only if the condition is true
b.) run a set number of times
c.)run at least once
d.)run when there are no conditionsso that you can read up to the ‘@’ character , stop and get the answer and then continue. You could make the while loop read one word at a time ( stopping when you read ‘@’ ) and then get the answer.
yeah but how to put it into coding??
- October 22, 2008 at 10:09 pm #3466GWILouisaxwzklaParticipant
This version works with this file format:
A for loop is designed to
a.)run only if the condition is false
b.)run a set number of times
c.)run at least once
d.)run when there are no conditions
@
A while loop is designed toa.)run only if the condition is true
b.) run a set number of times
c.)run at least once
d.)run when there are no conditions
@123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include <stdio.h>#include <stdlib.h>int main ( void ){int questionNum;char questions [ 80 ];char c; /*variable to hold character input by user*/char choice[2]; /*create character array*/int i = 0; /*initialize counter i*/FILE * pFile;char ch;pFile = fopen ( "c:\programs\data2.txt" , "r" );if ( pFile == NULL ){perror ("FILE COULD BE OPEN");return 1;}ch = getc ( pFile );while ( ! feof ( pFile ) ){printf("n___________________n");printf("n Question n");printf("___________________nn");while ( ch != '@'){putchar ( ch );ch = getc ( pFile );}/*end else*/printf( "nnENTER YOUR ANSWER HERE: "); /*prompts user to input answer*/c = getchar ();getchar ();choice [ i ++ ] = c;ch = getc ( pFile );printf ( "n press any 'ENTER' for next Questions: ");}printf ( "n answers: n" );int j = 0;while ( j < i ){putchar ( choice [ j ] ) ;printf ( "n" );j ++;}return 0;} - October 22, 2008 at 11:40 pm #3467RandolpNolenParticipant
yeah Tnx :P
- AuthorPosts
- The forum ‘C Programming’ is closed to new topics and replies.