akarl said:
No, but this is:
#include <stdio.h>
int main(void)
{
puts("hello");
return 0;
}
August
I have this exercise, now I am confused because I don't know what to
make out of its purpose.
In the Standard C library, the function puts( ) prints a char array to
the console (so you can say puts("hello")). Write a C program that
uses puts( ) but does not include <stdio.h> or otherwise declare the
function. Compile this program with your C compiler.
(Some C++ compilers are not distinct from their C compilers; in this
case you may need to discover a command-line flag that forces a C
compilation.) Now compile it with the C++ compiler and note the difference.
*********************main.c********************
//main.c
int main(void){
puts("hello");
return 0;
}
********************makefile********************
cproj: main.o
gcc -o $@ main.o
#did not work
#cproj2: main.o #another way of doing it
#insert <tab> here, g++ -x c -o $@ main.o
cppproj: main.o
g++ -Wall -o $@ main.o
clean:
rm -f *.o cp*
********************output********************
$ make clean
rm -f *.o cp*
$ make cppproj
cc -c -o main.o main.c
g++ -Wall -o cppproj main.o
$ ls
cppproj main.c main.o makefile
$ make cproj
gcc -o cproj main.o
$ ls
cppproj cproj main.c main.o makefile
$ ./cppproj
hello
$ ./cproj
hello
so it compiled all fine and ran ok, what the point?
thank you