Re: [Dev-C++] Please help me...why doesn't the code compile?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2001-08-12 01:30:31
|
At 23.56 10/08/01 +0000, you wrote:
Hello Jose!
I tried your code (after storing it in 3 different files) with Dev C++. I
made a project and asked the IDE to compile it: everything seemed fine (no
compilation errors), but when I tried to execute it ... I had troubles! :-)
Unlike me, you had some compilation error, I guess it is because you turned
on some extra warnings, while I used only the "plain" Dev C++ options.
When I tried to compile your program from the command line (see the file
main.mk) I got these kind of errors:
- main should return an integer
- you are passing a "const char *" where a "char *" is expected
Maybe the second kind of error needs some comment.
Your prototype says: "extern char* LCase(char *str);" (by the way the
"extern" is not necessary), so a "char *" is expected. In your test
program, when you call the function by the line: "LCase("This is a test of
LCase\n");", you are handing it a "const char *" (a "string constant" to be
more specific). Usually compilers store string constants in a sort of read
only memory, so when you attempt to modify them you'll get (at least) a run
time error.
I suggest that you modify main.cpp in this way:
- build a "char *" using a constant string, and use hand it to your functions
I've changed your main.cpp according to the above, I also used "C style
strings". Since you are using C++ I suggest you use "C++ style strings"
(see your documentation on the standard library).
Hope this helps.
>Please help me anyone... :-)
>There are actually three files here; main.cpp, module1.cpp, and main.cpp.
>I'm ...
--
gisan
gi...@li... |