How would I use strcat to add the number stored in a var?

Non-platform specific questions.

How would I use strcat to add the number stored in a var?

Postby Hblade » Wed Jul 22, 2009 4:53 pm

I'm trying to make something that will add a textNumber. kinda like a timer but not exactly a timer, I'm using this code:
Code: Select all
double sec;
double minutes;
double hours;

I'm trying to make a fake clock, for a cutscene in the game, but I cant seem to add "hours, secs, and minutes" to the clock using strcat, is there any way that this can be done? My current code is
Code: Select all
strcpy(text, "");
    strcat(textNumber, hours);
    strcat(text, ":");
    strcat(textNumber, minutes);
    strcat(text, ":");
    strcat(textNumber, sec);

But that dosnt seem to work, I get this message


Error message.jpg
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: How would I use strcat to add the number stored in a var?

Postby makslane » Wed Jul 22, 2009 5:44 pm

You must use the sprint function, for example:

Code: Select all
sprintf(text, "The time is: %f:%f:%f", hours, minutes, sec);


Read more:
http://www.cplusplus.com/reference/clib ... o/sprintf/
http://www.cppreference.com/wiki/c/io/sprintf
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: How would I use strcat to add the number stored in a var?

Postby Hblade » Wed Jul 22, 2009 5:45 pm

Wrong arduments for STRCPY it says
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: How would I use strcat to add the number stored in a var?

Postby makslane » Wed Jul 22, 2009 10:51 pm

Sorry, use sprintf
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron