char* ch;
a_FileHandle = s3eFileOpen("LabValues.csv", "r");
int j=0;
ch = new char[100];
while(s3eFileReadString(ch,100,a_FileHandle)!=0)
{
//the above loop read one string at a time from a file including newline charater
items[j++] = ch;//copying string to character pointer array
ch = new char[100];
}
s3eFileClose(a_FileHandle);
} in the above code am reading strings from a file the deffect here is it will read ne line character also.
when i start copying the string i don't want to copy the newline character
with that character itself am not able to compare with the another string which has same name but doesnot have the newline character
plz help me how to remove the newline chracter from the string..
you dont have to do ch = newchar[100];
it should work with out it.
you always get 100bytes of new memory but dont delete the old one, so you waste a lot of memory.
if it does not work without new (but i dont know why it should not) use delete[] ch; before ch = newchar[100];
but to your question:
i assume you dont want to add the "new line" to your items array.
try
1 2 3
if (ch != '\n') {
items[j++] = ch;
}
a spontaneous idea (i dont have any chance to test this now, sorry)
maybe you also need to check for \r on windows (if someone could confirm or refute this, it would be nice, cuz im not sure)
sorry dude ..
i already mentioned that while(s3eFileReadString(ch,100,a_FileHandle)!=0) read one string at a time
lets assume there is a string "astrology"
it reads that string like "astrology#" assume #is a newline character
and how to delete that character is my question
if (ch != '\n') {
items[j++] = ch;
}
i think as per your code mentioned above you want me to read character by character and check for "\n"
but it is not possible here