Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C++] sscanf (Reading String with spaces)

Newbie Spellweaver
Joined
Jun 27, 2010
Messages
53
Reaction score
66
Hi, this is a simple tut how to read string with spaces...

Example:
Code:
12 02 2012 16 02 0 Server Powered by LOL!

Solution:
PHP:
			sscanf(this->CurrentLineString, "%d %d %d %d %d %d %[^\t]s",&this->NewsSystemList[this->NewsCount].Day,
																	 &this->NewsSystemList[this->NewsCount].Month,
																	 &this->NewsSystemList[this->NewsCount].Year,
																	 &this->NewsSystemList[this->NewsCount].Hour,
																	 &this->NewsSystemList[this->NewsCount].Minute,
																	 &this->NewsSystemList[this->NewsCount].Type,
																	 &this->NewsSystemList[this->NewsCount].Line);


Code:
%[^\t]s
By using this, scanf will read whole string until end of line or when tab seperation will detected...

You can experiment by changing [^\t] to [^ ], etc..
 
Back
Top