0

dear sir...
i got a confusing of this...

ifstream is;
			Char c, temp_isi_file[100];			
			int i;
		    is.open ("b.a");
			memset(temp_isi_file,'\0',100);
			while (is.good())     // loop while extraction from file is possible
			{
				c = is.get();
				if (is.good())
					if (c==',')
				    {
						//cout << temp_isi_file << ":" ;	

						textBox1->Text = Convert::ToString(temp_isi_file);
						
						i=0;
						c='\0';
						memset(temp_isi_file,'\0',100);
					}
					else
					{
						temp_isi_file[i]=c;
						i++;
					}
			}
label2->Text = Convert::ToString(temp_isi_file);

when I, show temp_isi_file to textbox,, the value is true. but I think, it should be the content of my file b.a. So, I don't know how to get the value "temp_isi_file"???
And then, I wanna convert the value "temp_isi_file" to binary. did I true to convert the file by convert it per temp_isi_file??

b.a
11111,33333,4444
temp_isi_file value, it should be 11111 and then 33333, 4444.

thanks before...

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by VIkhers
0

Instead of reading the file one character at a time, why not use getline() to read the entire line?

while( ls.getline( temp_isi_file, sizeof(temp_isi_file), ',') )
{
     // now temp_isi_file only contains one integer
     int n = atoi(temp_isi_file);

    // or if you prefer c++
    stringstream str(temp_isi_file);
    int n;
    str >> n;
}
0

dear sir,,
if I use this,,

while( ls.getline( temp_isi_file, sizeof(temp_isi_file), ',') )
{
     // now temp_isi_file only contains one integer
     int n = atoi(temp_isi_file);

    // or if you prefer c++
    stringstream str(temp_isi_file);
    int n;
    str >> n;
}

I, should be difficult of formatting the type of my data. because,, my file's content.. don't have one data type only. not for integer only but string, char, etc. if I use my code.. is there the way I got the value??

thanks..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.