Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,265 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,509 people online right now. Registration is fast and FREE... Join Now!




Removing tab chars in a file.

 
Reply to this topicStart new topic

Removing tab chars in a file., dosnt seem to work

chris.tkd
2 Dec, 2006 - 08:15 AM
Post #1

D.I.C Head
Group Icon

Joined: 26 Sep, 2006
Posts: 60


Dream Kudos: 25
My Contributions
hey im riting a program to remove the un needed formatting from a c file.

im having a little trouble removing the spaces after the lines have finished.

Eg
CODE

printf("...");
scanf("%d",&hi);


would be
CODE

printf("...");                              scanf("%d",&hi);

i have tryed using
CODE

if(ch=='\t')
ch=' ';


but it didnt work so i assume these are just spaces and not tabs so i tryed
CODE

if((ch=fgetc(input))==' ')//if char == space
{
     ch=fgetc(input);//get the next char
     while(ch==' ')
          ch=fgetc(input);//get a char thats not a space
}
fputc(' ',output);
fputc(ch,output);


but it dosnt work , can anyone suggest a method of gettin rid of those nasty spaces?


User is offlineProfile CardPM
+Quote Post

msg555
RE: Removing Tab Chars In A File.
2 Dec, 2006 - 09:07 AM
Post #2

D.I.C Head
Group Icon

Joined: 4 May, 2006
Posts: 136



Thanked: 2 times
Dream Kudos: 25
My Contributions
Try making your code remove a spce if it's proceeded by another.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:26PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month