Replace and Split...

08/29/2012 16:51 ernilos#1
I'm fairly new in c, and I have two questions.
1. How I can replace letters in a variable? (login_packet) (~ to nothing)
2. How I can split the var login_packet? (with " ")
Thanks ..
08/29/2012 20:35 MrSm!th#2
Quote:
1. How I can replace letters in a variable? (login_packet) (~ to nothing)
You have to search for '~' (for example via strchr) and copy the whole string into a new one leaving out the found characters.

Quote:
2. How I can split the var login_packet? (with " ")
Thanks ..
Well, what do you mean?
Splitting one string that includes spaces into those substrings, seperated by the spaces?
If so, strtok may be of your interest.
08/29/2012 21:44 ernilos#3
M.. I have that:
login_packet = "NoS0575 3995441 ernilos 10956354732165E3649465C265F47B3 00944304 0.9.3.2993 0 E472C68B9D7CB984A0AF7CD1A19B56C8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
remove the'~'
and split likes that:

NoS0575
3995441
ernilos
10956354732165E3649465C265F47B3
00944304 0.9.3.2993
0
E472C68B9D7CB984A0AF7CD1A19B56C8

Help.. :c
08/29/2012 21:53 MrSm!th#4
I already told you.