Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

a function problem

Posted on 2000-03-03
9
Medium Priority
?
231 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
Technology Partners: 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 2

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 2

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 20 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

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!

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

916 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