Skip to content

Commit 9467f36

Browse files
fixing tm.c
1 parent a72f496 commit 9467f36

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tm

3.77 KB
Binary file not shown.

TM.C renamed to tm.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ int readInstructions (void)
236236
lineNo = 0 ;
237237
while (! feof(pgm))
238238
{ fgets( in_Line, LINESIZE-2, pgm ) ;
239-
inCol = 0 ;
239+
inCol = 0 ;
240240
lineNo++;
241241
lineLen = strlen(in_Line)-1 ;
242242
if (in_Line[lineLen]=='\n') in_Line[lineLen] = '\0' ;
@@ -268,7 +268,7 @@ int readInstructions (void)
268268
if ( (! getNum ()) || (num < 0) || (num >= NO_REGS) )
269269
return error("Bad second register", lineNo, loc);
270270
arg2 = num;
271-
if ( ! skipCh(','))
271+
if ( ! skipCh(','))
272272
return error("Missing comma", lineNo,loc);
273273
if ( (! getNum ()) || (num < 0) || (num >= NO_REGS) )
274274
return error("Bad third register", lineNo,loc);
@@ -354,7 +354,7 @@ STEPRESULT stepTM (void)
354354
{ printf("Enter value for IN instruction: ") ;
355355
fflush (stdin);
356356
fflush (stdout);
357-
gets(in_Line);
357+
fgets(in_Line, LINESIZE-2, stdin);
358358
lineLen = strlen(in_Line) ;
359359
inCol = 0;
360360
ok = getNum();
@@ -364,7 +364,7 @@ STEPRESULT stepTM (void)
364364
while (! ok);
365365
break;
366366

367-
case opOUT :
367+
case opOUT :
368368
printf ("OUT instruction prints: %d\n", reg[r] ) ;
369369
break;
370370
case opADD : reg[r] = reg[s] + reg[t] ; break;
@@ -407,7 +407,7 @@ int doCommand (void)
407407
{ printf ("Enter command: ");
408408
fflush (stdin);
409409
fflush (stdout);
410-
gets(in_Line);
410+
fgets(in_Line, LINESIZE-2, stdin);
411411
lineLen = strlen(in_Line);
412412
inCol = 0;
413413
}
@@ -557,7 +557,7 @@ int doCommand (void)
557557
/* E X E C U T I O N B E G I N S H E R E */
558558
/********************************************/
559559

560-
main( int argc, char * argv[] )
560+
int main( int argc, char * argv[] )
561561
{ if (argc != 2)
562562
{ printf("usage: %s <filename>\n",argv[0]);
563563
exit(1);

0 commit comments

Comments
 (0)