Solved

a function problem

Posted on 2000-03-03
9
225 Views
Last Modified: 2010-04-02
Could You help me to write a function that would remove trailing blanks
and tabs from each line of input, and it would delete entirely blank lines.
Thank You!
0
Comment
Question by:Lora
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2581806
I could but not for 5 pts...  Maybe someone else needs them badly enough to bite.
0
 

Author Comment

by:Lora
ID: 2581817
I'm really sorry that's all I've got.
0
 
LVL 2

Expert Comment

by:homer99
ID: 2581882
Are you referring to an input stream.






0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:Lora
ID: 2581887
Yes.
Please help me with this problem.
0
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2581888
If you want to use CStrings, you can use TrimLeft and TrimRight.

Basically, your code would look like this:

   CString myStr;
   
   // Set the value of myStr here
   
   
   myStr.TrimLeft();
   myStr.TrimRight();
   while(myStr.Replace("\r\n\r\n", "\r\n") > 0) ;
   while(myStr.Replace("\n\n", "\n") > 0) ;

I can write code using traditional DOS string functions if you like.
0
 

Author Comment

by:Lora
ID: 2581895
Can you please write it using traditional DOS string function
0
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2582282
This will take a little while.  I'll try to have it posted as soon as possible.
0
 
LVL 33

Accepted Solution

by:
hongjun earned 5 total points
ID: 2582587
You mean to remove all white spaces and blanks is it?

#include <stdio.h>

void main()
{
    char string[20];
    int i=0;

    printf("Please enter the string below\n");
    fflush(stdin);
    gets(string);

    while ( string[i] )
    {
      if ( string[i] != ' ' )
          printf("%c",string[i]);
          i++;
    }
}

Hope it helps
hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 2582588
Hope you will give me more points and a better grade if you have the points.

Thanks
hongjun
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question