Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone help to code this program?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
should display the following ;
x x xxx
xx x x x
x x x x x
x xx x x
x x xxx

from this file

100010000111Y
1100100010001Z
10101001000001Y
1001100010001Z
100010000111Z
E

/* CH8A.C */
/* Interprets lines of A's and B's */
#include <stdio.h>
main ()
{
/* Description ......
Open input file
Read first character
WHILE not at end of file
WHILE not at end of line
IF character = A
Display X
ELSE
Display a space
Read next character
Read past newline and read 1st character on next line
Move to next line in output
Close input file
*/

/* variable declarations */


char current_character;


FILE *ch8a01 = fopen (&quot;ch8a01.dat&quot;, &quot;r&quot;);

fscanf (ch8a01, &quot;%d&quot;, &current_character);

while (current_character != &quot;E&quot;);
while ((current_character != &quot;Y&quot;) || (current_character != &quot;Z&quot;));
{
if (current_character = &quot;A&quot;);
printf (&quot;X&quot;);
else (current_character = &quot; &quot;);
printf (&quot; &quot;);
}
fscanf (ch8a01, &quot;%d&quot;, &current_character);


fclose (ch8a01);



getch ();

}


Can you plaese help me get the right coding
 
well it looks like you got an infinte loop with yoru while, and you are looking for &quot;A&quot; when you should be looking for &quot;1&quot;

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top