Solved

a function problem

Posted on 2000-03-03
9
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

636 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