i';我无法在devc+;中编译简单的C函数程序+;?

i';我无法在devc+;中编译简单的C函数程序+;?,c,dev-c++,C,Dev C++,我正在尝试用Dev-C++进行编译, 计划是: main( ) { message( ) ; printf ( "\nCry, and you stop the monotony!" ) ; } message( ) { printf ( "\nSmile, and the world smiles with you..." ) ; } 错误包括: E:\Dev\fn.cpp [Error] 'message' was not

我正在尝试用Dev-C++进行编译, 计划是:

main( )
{
    message( ) ;
    printf ( "\nCry, and you stop the monotony!" ) ;
}

message( )
{
    printf ( "\nSmile, and the world smiles with you..." ) ;
}
错误包括:

E:\Dev\fn.cpp [Error] 'message' was not declared in this scope
E:\Dev\fn.cpp [Error] ISO C++ forbids declaration of 'message' with no type [-fpermissive]

编辑:愚蠢的错误。编译<代码> C <代码>程序为<代码> CPP < /代码>

首先编译C代码为C代码,而不是C++代码。C代码的扩展名应该是
.C
,而不是
.cpp

然后,认识到书中可能有错误的东西和正确的代码。 您不应该忽略返回值和参数的类型,使用的函数应该在使用之前声明

试试这个:

#include <stdio.h> /* declaration of printf() will be here */

/* bring this function before using */
void message(void)
{
    printf ( "\nSmile, and the world smiles with you..." ) ;
}

int main(void)
{
    message( ) ;
    printf ( "\nCry, and you stop the monotony!" ) ;
    return 0;
}
#include/*printf()的声明将出现在这里*/
/*使用前请先使用此功能*/
无效消息(void)
{
printf(“\n英里,世界向你微笑……”);
}
内部主(空)
{
消息();
printf(“\nCry,你停止单调!”);
返回0;
}

<代码>你是用C编写代码,还是编译成C++?这不是C,也不是C++,所以不足为奇。我相信这本书在教授陈旧过时的东西方面名声不好。如果它是一本C语言的书,你应该试着用C编译器编译。此外,这本书看起来可能是C89之前的标准。许多C编译器将对该代码进行巴氏处理。请记住C和C++是两种完全不同的语言,而你使用的书是负值,所以扔掉它等于利润。@ Juangophanz这是标准C89(如果包含适当的标题)。请问哪位编译器会吐出那个代码?我一个也不认识。