Help with splitting strings

Hi,
My goal with the attached code was to read in strings via splitting the string, using a switch statement, and then to return the contents of the CSV data such that it appears without commas in the output file. In my current code, it returns everything but still has the comma in between the pieces of data. I am using a struct in this code, and am also returning the name. However, when I output that, it shows the name such that the first and last names are not separated. I was wondering how I would fix this, without using STL or Vector, but such that I can keep my current approach to how I process the data. Thank you for the help.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  ofstream progOutput;
	progOutput.open(output, std::ios_base::app);

	string oneLine;
	int splitCounter = 0;
	std::istringstream  inputString;
	inputString.str(addLine);
	splitCounter = 0;
	string recordToBeAdded;	
	accountInfo a;
		
	while (getline(inputString, oneLine, ' ')) 
	{ 
		switch (splitCounter)
		{
		case 0:
			
			a.name = oneLine; 
			
			break; 
		case 1: 
			a.id = oneLine; 
			break; 
		case 2:
			a.account = oneLine; 
			break; 
		case 3: 
			a.username = oneLine; 
			break; 
		case 4: 
			a.password = oneLine; 
			break; 

		
		
	

		default: 
			break;
			
			
			
		}
		progOutput << "add" << " " << a.name << " " << a.id << " " << a.account << " " << a.username << " " << a.password << endl;
splitCounter += 1;
	}
Can you post your full code?
Topic archived. No new replies allowed.