Well basically i tried many ways. And it all works, but not on the way i expected tho.
- Code: Select all
int checksum; checksum = 1;
void flinem(const char * fileName, char * id, int fmax)
{
FILE * file = fopen(fileName, "r");
char database[256];
if (id[fmax] == 32 && checksum == 1) {database[0] = 1; checksum = 0;} else { checksum = 1; }
if (id[fmax-1] == 32 && checksum == 1) {database[1] = 1; checksum = 0;} else { checksum = 1; }
if (id[fmax-2] == 32 && checksum == 1) {database[2] = 1; checksum = 0;} else { checksum = 1; }
if (id[fmax-3] == 32 && checksum == 1) {database[3] = 1; checksum = 0;} else { checksum = 1; }
if (id[fmax-4] == 32 && checksum == 1) {database[4] = 1; checksum = 0;} else { checksum = 1; }
if (strlen(id) > fmax) {
if (database[0] == 1) id[fmax] = '\n';
if (database[1] == 1) id[fmax-1] = '\n';
if (database[2] == 1) id[fmax-2] = '\n';
if (database[3] == 1) id[fmax-3] = '\n';
if (database[4] == 1) id[fmax-4] = '\n';
}
}
The little code should find the last spaces behind the last 5 characters in a line of a text file. And if it finds the first, it does not look for another.
That should work but it still does not. I'm trying to figure out why the heck that is..
That does not work, because it sends sometimes only one character to a new line..