writting in .csv file

Hi ,
I am trying to saggrigate some data and trying to write into different columns of .csv or .xls file . But not knowing how to start .
making it short i have ..

e.g

1
2
3
4
LPTSTR name , grade , school; 
cin>>name; 
cin>>grade;
cin>>school;


these three variable should be in the different columns .
I have googled it but it seem that they are all inputing it in the single column in the csv or xls file ...

Just need a start as how to write it
Thanks in advance
Last edited on
This code will segfault because you haven't allocated any space to hold the strings. LPTSTR is a windows typedef that will either end in a char* or wchar_t*. Unless you absolutely must use LPTSTR I'd suggest using a std::string:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <string>
std::string name, grade, school;
std::cout << "What is your name? : ";
std::getline(std::cin,name);
std::cout << std::endl << "What grade are you in? : ";
std::getline(std::cin,grade);
std::cout << std::endl << "Which school do you attend? : ";
std::getline(std::cin,school);


Last edited on
Topic archived. No new replies allowed.