problem of a simulator

closed account (Gb4iNhU5)
solved.
Last edited on
> printf("A = "); int a = (int)(fgets(buff, 64, stdin));
> printf("\nB = "); int b = (int)(fgets(buff, 64, stdin));
I can't imagine how you thought this could possibly work.

> this->A << a; this->B << b;
Are these expecting an int (as maybe suggested by your hackery casting), or a string?

If you're expecting a string, note that you only have ONE char array, so whatever you typed in last will be what you'll get for both a and b.

Maybe, dunno.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
			char buff[64];
			char b_buff[64];
			printf("A = ");  fgets(buff, 64, stdin);
			printf("\nB = ");  fgets(b_buff, 64, stdin);
			if (*buff == 'q')
				break;
			if (*buff == 'l')
			{
				SimArchive::loadSimulation("GCD.vcd");
				printf("Simulation restored from GCD.vcd\n");
			}
			else if (*buff == 's')
			{
				SimArchive::saveSimulation("GCD.vcd");
				printf("Simulation saved to GCD.vcd\n");
				continue;
			}
			this->A << buff; this->B << b_buff;
			Sim::run();
			printf("\nGCD is: %d", this->GCD);
			Sim::reset();

Topic archived. No new replies allowed.