Solved

a function problem

Posted on 2000-03-03
9
227 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

679 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