Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Add extension to a file
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Scholar




PostPosted: Mon Jul 07, 2014 7:37 pm   Post subject: Add extension to a file

So basically I want to do something similar to:
C:

strcpy(current_file, new_file);
strcat(new_file, ".saved_game");
MoveFile(new_file, current_file);


Where current file is a certain .txt file containing co-ordinates for my game, I just want to add the .saved_game extension to the text file so
LPSTR new_file = all the above ^^

How would I do this since my g++ compiler isn't liking the type of strings im using. It just crashes here and says that there is a stack error on strcpy()?

note current_file & new_file are LONG * string -> LPSTR

How could I do this? Add .saved_game extension to the current_file?
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Jul 07, 2014 9:24 pm   Post subject: RE:Add extension to a file

Quote:
note current_file & new_file are LONG * string -> LPSTR


Does strcpy take that type as input?
Scholar




PostPosted: Mon Jul 07, 2014 10:21 pm   Post subject: RE:Add extension to a file

Yes sir, but don't tell me "the pre-defined parameters are char* ". I know this, if you could give me some way I can get around that or some alternative that would be much appreciated. I haven't really tried anything else so I couldn't tell you anything more. But please, if you will, some "bypass" would be greatly appreciated.
Dreadnought




PostPosted: Mon Jul 07, 2014 10:48 pm   Post subject: Re: Add extension to a file

You might be looking for wcstombs (converts wide-character strings to multi-byte character strings).
Scholar




PostPosted: Mon Jul 07, 2014 11:48 pm   Post subject: RE:Add extension to a file

Isn't this the same as just passing the platform encoding as multi-byte characters in the project settings which I already have it set. Doesn't that eliminate the need for this function?
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: