|
这是一个链栈的演示程序.
选择1,为入栈操作.选择2,为出栈.
选择3,为清空操作,选择4,为退出.
TC能够正确的编译出来,但是GCC就报错,而且报的错误莫名其妙.如下:
z2.c:55: stray '\32' in program
z2.c:55:2: warning: no newline at end of file
我这个程序只有54行,哪里出来的55行啊?
郁闷+茫然.
1 #include<stdio.h>
2
3 void clear(char array[6])
4 {int i;
5 for (i=0;i<6;i++)
6 array='-';
7 }
8
9 void insert(char array[6])
10 {int i;
11 char x;
12 flushall();
13 printf("Enter a char which you will insert: ");
14 x=getchar();
15 for (i=0;i<6;i++)
16 if (array=='-') break;
17 array=x;
18 }
19 void delete(char array[6])
20 {int i;
21 for (i=0;i<6;i++)
22 if (array=='-') break;
23 array[i-1]='-';
24 }
25
26 main()
27 {int i,x;
28 char a[6]={'-','-','-','-','-','-'};
29
30 loop:flushall();
31 printf(" Viaduct Of Program \n");
32 printf("===========================================\n");
33 printf("| 1.Input viaduct | 2. Output viaduct |\n");
34 printf(" | 3.Clear empty | 4. Out program |\n");
35 printf("===========================================\n");
36 printf("\n");
37 printf("Enter your choose (1 to 4): ");
38 scanf("%d",&x);
39 while(x<1 || x>4)
40 {flushall();
41 printf("Data error ! Input 1 to 4 again: ");
42 scanf("%d",&x);
43 }
44 while(x!=4) 45 {switch (x)
46 {case 1:insert(a);break;
47 case 2:delete(a);break;
48 case 3:clear(a);break;};
49 for (i=0;i<6;i++)
50 printf("%5c",a);
51 printf("\n");printf("\n");printf("\n");
52 goto loop;};
53 printf("The program over, Thanks for you used.\n");
54 } |
|