|
我的。c文件是
- #include <stdio.h>
- #include <stdlib.h>
- #include "tri.h"
- #include "hello.h"
- int main()
- {
- tri();
- hello();
- }
复制代码
.h文件是
- #define n 5
- #define m 4
- int tri()
- {
- long i, j, k;
- for (i = 0; i < n; i++)
- {
- j = n - i;
- for (k = 0; k < = j; k++)
- printf(" ");
- for (k = 0; k < 2*i+1; k++)
- printf("*");
- printf("\n");
- }
- for (i = m; i >0; i--)
- {
- j = m - i + 1;
- for (k = 0; k < = j+1; k++)
- printf(" ");
- for (k = 0; k < = 2*(i-1); k++)
- printf("*");
- printf("\n");
- }
- return 0;
- }
复制代码
- void hello()
- {
- printf("hello world");
- }
复制代码
不能生成可执行文件
我用的是
$ gcc tri.c -o hello
In file included from tri.c:3:
tri.h: 在函数 ‘tri’ 中:
tri.h:9: 错误: expected expression before ‘=’ token
tri.h:18: 错误: expected expression before ‘=’ token
tri.h:20: 错误: expected expression before ‘=’ token |
|