In My C++/VC++ program:
/* Snippets of Code */
for (int z=0;z<50;z++)
{
atemp1 = CString("A");
btemp1 = CString("B");
//Column A - Of Excel
app.SetDisplayA lerts(FALSE);
oRange = oSheet.GetRange (COleVariant (atemp1),COleVa riant
(atemp2));
CString peak_memoryUsag e = read_file("a",i n);
int buf[z-1] = (int)read_value s("a",in);
oRange.SetValue 2(COleVariant(b uf[z-1]));
}
int read_values(CSt ring str1,ifstream in)
{
int pos;
char lineone[256];
char buf[200];
char buff[1024];
CString filename=ptr;
int status;
status = _open(filename, _O_RDONLY);
if(status == -1)
{
printf("Couldno t able to Open file ");
}
else
{
printf("Opening of file Successful");
}
pdest=strstr(li neone,str1);
pos = pdest - lineone + str1.GetLength( );
if (!in.eof())
{
in.getline(line one,sizeof(line one),'\n');
if(str1 == ",") /* If got a comma */ In this exp:
"a",(Comma)
{
printf("\n");
for(i=0;i<=50;i ++) /* No of Rows */
{
/* Here is the Problem */
Question is :How I will return a Buffer
of integer to the calling program column wise? */
pos=1;
/* Here I need to return buff[i] to the calling program
(10
40 pos = pdest - lineone +
str1.GetLength( );
70 ) How???
*/
return buf;
}
/* pos =pdest -lineone+str1.Ge tLength(); */
}
}
}
CString read_file(CStri ng str1, ifstream in)
{
char *pdest;
int pos;
char lineone[256];
if (!in.eof())
{
in.getline(line one,sizeof(line one),'\n');
pdest = strstr(lineone, str1);
while (pdest == 0)
{
in.getline(line one,sizeof(line one),'\n');
pdest = strstr(lineone, str1);
}
CString s = lineone;
CString s1 = s.Mid(pos);
return s1;
}
else
{
return "EOF";
}
}
"Chris Theis" <Ch************ *@nospam.cern.c h> wrote in message news:<c0******* ***@sunnews.cer n.ch>...
"Sobhan" <bu*********@ya hoo.co.in> wrote in message
news:81******** *************** ***@posting.goo gle.com... Hi all,
I am writing a program in C++ in which I need to read a data
file and export to the excel.The Data in the file in CSV format.
Values in the .txt file are as follows:
"a","b","c"
10,20,30
40,50,60
70,80,90
For that I need to read the values column wise.
Like I have to store the values in a buffer like the following:
"a",
10,
40,
70
etc.
I did the following:
1.Open the file in Read Mode
2.Read line by line
3.Search for comma
4.When Got comma
Printf("\n");
5.Problem is how I will return the buffer(Which is set of integers) to
calling program reading the data values column wise???
Regards
Bubunia
You can return a vector of a vector (=matrix) storing your values. However,
show some code which allows people to give more specific answers.
Chris