sprintf(SendFocusScreenMessage(),"%s \"%s\" aged %i was transfered to our ship",Crew.GetCrewMiscIdByName(Crew.GetLastEnteredCrewName()),Crew.GetLastEnteredCrewName(),Crew.GetCrewAgeByName(Crew.GetLastEnteredCrewName()));
When Itry to compile this line whit Dev-C++, the compiler gives me this error
" implicit declaration of function `int sprintf(...)' "
What do I have to correct
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
int ReturnCode=Crew.ProcessUniversalMMu();
switch(ReturnCode)
{
case UMMU_TRANSFERED_TO_OUR_SHIP:
sprintf(SendFocusScreenMessage(),"%s \"%s\" aged %i was transfered to our ship",Crew.GetCrewMiscIdByName(Crew.GetLastEnteredCrewName()),Crew.GetLastEnteredCrewName(),Crew.GetCrewAgeByName(Crew.GetLastEnteredCrewName()));
break;
case UMMU_RETURNED_TO_OUR_SHIP:
sprintf(SendFocusScreenMessage(),"%s \"%s\" aged %i entered into our ship",Crew.GetCrewMiscIdByName(Crew.GetLastEnteredCrewName()),Crew.GetLastEnteredCrewName(),Crew.GetCrewAgeByName(Crew.GetLastEnteredCrewName()));
break;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note that the error message about an implicit definition means that the compiler doesn't know what that function is. In this case, with a function like sprintf, this may mean that you have not included the appropriate header that tells the compiler what the function is.
This means that posting single lines of code, or even entire functions will probably not be sufficient to figure things out. This is why having a stand-alone piece of example code is a much better way to get help.
Is this code you have written, or are you just trying to compile code someone else has given you?
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please stop excerpting errors - you are throwing away vital information - which is why I keep asking for your "Basic 3".
I see two things from what you posted:
(1) It looks like you are storing your project in a path with spaces in it,probably "My Documents" - this is a very bad idea.
(2) The error message about not finding WinMain is actually discussed in the FAQ - you probably either do not have a main function in a console application, or lack a WinMain if you are compiling a windows application.
Jumping to a conclusion here - it looks like someone gave you source code for a game or something, and you are trying to compile it without a lot of knowledge about coding - you just want to play the game, right?
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sprintf() is explicitly declared in <stdio.h> / <cstdio>
In C++ it is illegal to have an implicit declaration, in C it is valid and the compiler will only generate a warning, but even in C it is not a good idea.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sprintf(SendFocusScreenMessage(),"%s \"%s\" aged %i was transfered to our ship",Crew.GetCrewMiscIdByName(Crew.GetLastEnteredCrewName()),Crew.GetLastEnteredCrewName(),Crew.GetCrewAgeByName(Crew.GetLastEnteredCrewName()));
When Itry to compile this line whit Dev-C++, the compiler gives me this error
" implicit declaration of function `int sprintf(...)' "
What do I have to correct
Well, your Basic 3 would be a much better place to start than a single line of code and an error message...
Wayne
int ReturnCode=Crew.ProcessUniversalMMu();
switch(ReturnCode)
{
case UMMU_TRANSFERED_TO_OUR_SHIP:
sprintf(SendFocusScreenMessage(),"%s \"%s\" aged %i was transfered to our ship",Crew.GetCrewMiscIdByName(Crew.GetLastEnteredCrewName()),Crew.GetLastEnteredCrewName(),Crew.GetCrewAgeByName(Crew.GetLastEnteredCrewName()));
break;
case UMMU_RETURNED_TO_OUR_SHIP:
sprintf(SendFocusScreenMessage(),"%s \"%s\" aged %i entered into our ship",Crew.GetCrewMiscIdByName(Crew.GetLastEnteredCrewName()),Crew.GetLastEnteredCrewName(),Crew.GetCrewAgeByName(Crew.GetLastEnteredCrewName()));
break;
}
The "Basic 3" are covered in the thread titled "Please Read Before Posting a Question".
Wayne
Note that the error message about an implicit definition means that the compiler doesn't know what that function is. In this case, with a function like sprintf, this may mean that you have not included the appropriate header that tells the compiler what the function is.
This means that posting single lines of code, or even entire functions will probably not be sufficient to figure things out. This is why having a stand-alone piece of example code is a much better way to get help.
Is this code you have written, or are you just trying to compile code someone else has given you?
Wayne
I have add "#include <stdio.h>"
But when I try to compile the project there are no errors, but in the compiler and linker output there are more line like this.
C:\Docum........................... undefined reference to...................
and at the end there is
c:.................undefined reference to `WinMain@16'
Basic 3?
Read the thread titled "PLEASE READ BEFORE POSTING A QUESTION"?
Wayne
Please stop excerpting errors - you are throwing away vital information - which is why I keep asking for your "Basic 3".
I see two things from what you posted:
(1) It looks like you are storing your project in a path with spaces in it,probably "My Documents" - this is a very bad idea.
(2) The error message about not finding WinMain is actually discussed in the FAQ - you probably either do not have a main function in a console application, or lack a WinMain if you are compiling a windows application.
Jumping to a conclusion here - it looks like someone gave you source code for a game or something, and you are trying to compile it without a lot of knowledge about coding - you just want to play the game, right?
Wayne
sprintf() is explicitly declared in <stdio.h> / <cstdio>
In C++ it is illegal to have an implicit declaration, in C it is valid and the compiler will only generate a warning, but even in C it is not a good idea.
Clifford
Do you perceive a mismatch between the code and question Clifford?
Wayne
You mean sophisticated code, novice question?
New code maintainer perhaps?
Any how, I hope this code is for your Navy and not mine! ;)
Clifford