Hi,
I have a problem creating one part of the program,
Lets say we have a line (from data file): 333 hou 23se 444 bi 4g
and the program should change to : house big
deleting first number if there is one ,and changing word parts to numbers, and deleting "just numbers" from line like 444...
code:
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
#include <ctype.h>
#define FILENAME "file.txt"
int main(void)
{
char record[100], /* array to hold lines */
*fld1, *line,*kk; /* pointers to lines */
FILE *fin; /* pointer to input file */
int g,i; /* some integers... */
fin = fopen(FILENAME, "r"); /* open the file to read */
while (fgets(record, sizeof(record), fin))
{
if (record[strlen(record) - 1] != '\n')
record[strlen(record) - 1] = '\n'; //until new line
line = strtok(record, "\n"); //now we have a line to work with...
i = 0;
g = strlen(line);
// this part of program should delete first number if there s one like : 33 dd to :dd
while( isdigit(line[i]))
{
line[i]= line[i+1] ; //somethings wrong... :(
i=i+1;
}
// Ideas ?
printf("%s\n", line);
}
fclose(fin);
system("Pause");
return 0;
}