samedi 20 décembre 2014

Replace tabs with spaces in C [on hold]


i want to replace tabs with spaces but i didn't get it. I also tried to count the chars but that did also not work for me.


I just want to do it in c, no c++.


Here's what i have so far:



void ReplaceTabs(FILE *file)
{
int currChar = 0;

if (file != NULL)
{
while((currChar = fgetc(file)) != EOF)
{
if(int currChar = 0 == '\\')
{
currChar = fgetc(file);

if(currChar == 't') //
{
// Here's where i stuck ...
printf("\t");
}
else
{
putchar(92); // == \
putchar(currChar);
}
}
else
{
putchar(currChar); // To print the chars
}
}
}
else
printf("The file does not exists!");
}




Aucun commentaire:

Enregistrer un commentaire