You are here:

C++/Reading text files

Advertisement


Question
Hi Premnath,

I have a small question regarding accessing the text files in C++. Here is what I am writing in C++. Tha algorithm is as follows:
for j = 2:length(image)
{
         Red = image(j,1)+1;
}
where "image" loads/contains a text file and this text file is filled with strings seperated by tab. So how do i write the above algorithm in C++ to achieve the same effect.

Any help in this would be appreciated.

Thanks,
Rishi

Answer
Dear Mr Rishi !

 Sorry for the delay in responding you !
you have mentioned that the strings are separated with tab ( Make sure the TAB have fixed size ) here i present you a suggestion to acchieve the same effect

1.Read the text file character by character
2.If a space encounters for the first time ( without any hesitation you can skip the upcoming 5 spaces ( make sure this will be applicable only if TAB described with 5 consecutive spaces ! )
3.After jumping the spaces you can perform the usual operation !

Note : My time is of course limited that's why i am  unable to give you any code to explain the concepts , but im sure the idea what just i gave will work pretty fine !

Thanks and Regards !
Prince M. Premnath

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise

Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)

Experience

More than 5 years

Education/Credentials
MCA

©2016 About.com. All rights reserved.