Solved

a function problem

Posted on 2000-03-03
9
223 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
Comment Utility
I could but not for 5 pts...  Maybe someone else needs them badly enough to bite.
0
 

Author Comment

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

Expert Comment

by:homer99
Comment Utility
Are you referring to an input stream.






0
 

Author Comment

by:Lora
Comment Utility
Yes.
Please help me with this problem.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Expert Comment

by:poohbear_68
Comment Utility
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
Comment Utility
Can you please write it using traditional DOS string function
0
 
LVL 1

Expert Comment

by:poohbear_68
Comment Utility
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
Comment Utility
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
Comment Utility
Hope you will give me more points and a better grade if you have the points.

Thanks
hongjun
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now