Jump to content

How to read a unicode string using getline


Recommended Posts

Hi to all

i m having problem in reading a unicode string from a unicode formatted file can any one direct me how to read a string till a given delimenator the code i m writing is

char buffer =new char[2500];

memset(buffer,'\0',strlen(buffer));

fstream fp,fp1;

fp.open("c:\\filedata1.txt",ios::in);

if (!fp.is_open())

{

cout << "couldn't open file" << endl;

exit(3);

}

else

while(!fp.eof())

{

fp.getline(buffer,2500,'¶');

fp1.open("c:\\notfounddata2.txt",ios::out);

fp1.write(buffer,2500);

cout<<buffer;

memset(buffer,'\0',strlen(buffer));

}

fp.close();

fp1.close();

}

Link to comment
Share on other sites


Hi,

use the strstr function which gives you back the position of the first occurence of the wanted char's. Than read from the beginning of the string till this position.

when i need to read from a file till the occurence of a specific pattern i use a self written function which reads byte by byte and checks if i read the pattern i am looked for. post me a pm if you need those code.

Egon

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...