Thanks for the answer Salem. I'm sorry I can't find any information on how to apply the sscanf function in my code.
Now I've been trying all day with various methods and it's starting to <........> me off.
I really hope there's someone able and willing to help.
I've got the following piece of code...
Code:
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <windows.h>
int main(void)
{
FILE *file_pointer_in, *file_pointer_out;
char file_in[256],file_out[256], buf[BUFSIZ];
int ih, cnt=0;
bool space_flag=FALSE, skip_flag=FALSE;
printf("Please enter source file name: ");
scanf("%s",file_in);
if((file_pointer_in = fopen(file_in, "rb"))== NULL)
{
printf("Can't open source file\n");
getch();
return 1;
}
printf("Please enter destination filename: ");
scanf("%s",file_out);
file_pointer_out = fopen(file_out,"wb");
while((ih=fgetc(file_pointer_in))!=EOF)
{
while(skip_flag==FALSE)
{
while(cnt<3)
{
while((ih=fgetc(file_pointer_in))=='\n')
{ skip_flag=TRUE; cnt++; }
}
}
while((ih=fgetc(file_pointer_in))!=EOF)
if(ih==' '){ space_flag=TRUE; }
else
{
fputc(ih,file_pointer_out);
putch(ih);
if(space_flag)
{
space_flag=FALSE;
}
}
}
fclose(file_pointer_in);
fclose(file_pointer_out);
getch();
return 0;
}
Now what I want to do is read the input file line by line and save the data like I said in my first post. An input file would be like the one attached to this post.
Please note this code deletes the spaces from the input file. That's just a test for myself to see if I was able to manipulate the file, so that's where the function I just described should be placed.
Any help would be highly appreciated. Thanks very much in advance!