pep*_*dip 3 c declaration function
我收到此错误:
arthur@arthur-VirtualBox:~/Desktop$ gcc -o hw -ansi hw1.c
hw1.c: In function `main':
hw1.c:27:16: warning: assignment makes pointer from integer without a cast [enabled by default]
hw1.c: At top level:
hw1.c:69:7: error: conflicting types for `randomStr'
hw1.c:27:18: note: previous implicit declaration of `randomStr' was here
Run Code Online (Sandbox Code Playgroud)
在编译此代码时:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
char *rndStr;
rndStr = randomStr(FILE_SIZE);
/* Do stuff */
return 0;
}
/*Generate a random string*/
char* randomStr(int length)
{
char *result;
/*Do stuff*/
return result;
}
Run Code Online (Sandbox Code Playgroud)
如果我切换它周围的功能顺序,为什么呢?
除少数例外情况外,C语言中的标识符在声明之前不能使用.
以下是如何在其定义之外声明一个函数:
// Declare randomStr function
char *randomStr(int length);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7538 次 |
| 最近记录: |