Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with string/char......

Status
Not open for further replies.

Vallurupa

Programmer
Oct 17, 2001
38
US
How to convert from string to char.
Please help me....

/**********************************************/

#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <string>
#include <iostream>

FILE *fp;
char buff[51];
char *buff2;
char *buff3;
char *buff1[20];
string a[10];
string aa[10];
int result;

if( (fp = fopen( &quot;c:\\table1.dat&quot;, &quot;r&quot; )) == NULL )
MessageBox(NULL,&quot;The file was not opened&quot;,&quot;Message&quot;,MB_OK);
else
MessageBox(NULL,&quot;The file 'data' was opened, Reading Data&quot;,&quot;Message&quot;,MB_OK);
int i=0;
while( !feof(fp))
{
fread( buff, sizeof( char ), 51, fp );
buff1=buff;
buff2=buff;
MessageBox(NULL,buff2,&quot;message&quot;,MB_OK);

a=buff1;
aa[0]=a.substr(1,10);
aa[1]=a.substr(12,10);
aa[2]=a.substr(23,13);
aa[3]=a.substr(38,13);
//here i have to change these strings to chars.
//but it is giving error when i just do this
// buff3=aa[0]; Here could copy cahr to string but not in the other way. when i type cast wtih (char) also there it is giving error.


MessageBox(NULL,&quot;We are in the file now&quot;,&quot;Message&quot;,MB_OK);
i++;

}
fclose( fp );
}
/********************************************************/

I am keeping this code in DLL.
thanks

Tiaac
tiaacus@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top