- Joined
- May 19, 2007
- Messages
- 7,662 (1.16/day)
- Location
- c:\programs\kitteh.exe
Processor | C2Q6600 @ 1.6 GHz |
---|---|
Motherboard | Anus PQ5 |
Cooling | ACFPro |
Memory | GEiL2 x 1 GB PC2 6400 |
Video Card(s) | MSi 4830 (RIP) |
Storage | Seagate Barracuda 7200.10 320 GB Perpendicular Recording |
Display(s) | Dell 17' |
Case | El Cheepo |
Audio Device(s) | 7.1 Onboard |
Power Supply | Corsair TX750 |
Software | MCE2K5 |
Working on a basic text editor in c++ using linked lists
i have a method that that accesses a class method called add that accepts words froma stringt for example "the aflac duck" gets broken into three items by insert and and get added to a link list by insert. running on the assumption so far that each word has 1 space between it.
why if for example i do
where st1 is a string do i get "the" when i do a readback
as opposed to if i use
i have a method that that accesses a class method called add that accepts words froma stringt for example "the aflac duck" gets broken into three items by insert and and get added to a link list by insert. running on the assumption so far that each word has 1 space between it.
Code:
void insert(string w1)
{
string w2="";
char c1;
string::iterator it;
for (it=w1.begin(); it < w1.end(); it++)
{
c1 = *it;
if( c1 == ' ')
{
list.add(w2);
w2="";
}
else
{
w2 = w2 + c1;
}
}
}
why if for example i do
Code:
insert(st1);
where st1 is a string do i get "the" when i do a readback
as opposed to if i use
Code:
insert("the aflac duck");
i do a readback and get the whole string ... (the aflac duck)
what am i doing wrong