473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Plz solve my problem

nik
hello friends,

i want to create a file and copy that file removing white spaces in the
file;
for ex
a file : C:\\abcd.txt
contents of file r: a b c d e.
i want to remove white spaces from the file using skipws .
how can i do this.

Aug 17 '06 #1
4 1555

"nik" <am*******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
hello friends,

i want to create a file and copy that file removing white spaces in the
file;
for ex
a file : C:\\abcd.txt
contents of file r: a b c d e.
i want to remove white spaces from the file using skipws .
how can i do this.
Which part are you having trouble with?

Here's an outline to get you started:

open the input file
open another output file
while (read a line of the file into a string)
remove the white space
write the string to the output file
close the files

Now, read your class notes and your textbook, and also the FAQ, esp. section
5:

http://www.parashift.com/c++-faq-lite/

-Howard

Aug 17 '06 #2
nik wrote:
hello friends,

i want to create a file and copy that file removing white spaces in the
file;
for ex
a file : C:\\abcd.txt
contents of file r: a b c d e.
i want to remove white spaces from the file using skipws .
how can i do this.
Sure! Just post your instructor's email, and I will send the answer
to your assignment right over to him.
Socks

Aug 17 '06 #3
In article <11**********************@h48g2000cwc.googlegroups .com>,
"nik" <am*******@gmail.comwrote:
hello friends,

i want to create a file and copy that file removing white spaces in the
file;
for ex
a file : C:\\abcd.txt
contents of file r: a b c d e.
i want to remove white spaces from the file using skipws .
how can i do this.
Here you go. Paste the below in a file, and insert code where it says
"insert code here" until you can get the program to print "GOOD JOB!".
----------------------------------------------------------------------
#include <iostream>
#include <sstream>

using namespace std;

void copy_no_whitespace( istream& is, ostream& os )
{
// insert code here
}

int main() {
stringstream iss( "a" );
stringstream result;
copy_no_whitespace( iss, result );
assert( result.str() == "a" );

iss.str( "a b" );
result.str( "" );
iss.clear();
result.clear();
copy_no_whitespace( iss, result );
assert( result.str() == "ab" );

iss.str( " a b c " );
result.str( "" );
iss.clear();
result.clear();
copy_no_whitespace( iss, result );
assert( result.str() == "abc" );

cout << "GOOD JOB!\n";
}
Aug 17 '06 #4
"nik" <am*******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
hello friends,

i want to create a file and copy that file removing white spaces in the
file;
for ex
a file : C:\\abcd.txt
contents of file r: a b c d e.
i want to remove white spaces from the file using skipws .
how can i do this.
One way I would probably do it is by taking advantage of istream taking
white space as a delimiter. So I would create an ifstream opening the input
file, >to a std::string, then write the string to the output file. The
problem that you will have is when you get to the end of line '\n'. Not
sure how to know when you get there so you can get past it. Maybe someone
else can.

And the reason I didn't give you any code is because I suspect this is
homework.
Aug 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BVM | last post by:
Hi, All: I have this error. It seems execution time is too long. Actually the execution time is about 30 seconds(I tested in Query analyzer). How do I solve this problem? ...
3
by: Alex | last post by:
Hi, I have a problem involving some design issue. I have two unrelated (that is, they do not derive from the same base) classes: ClassA ClassB Both have a quite similar interface, so they can...
7
by: Shapper | last post by:
Hello, I have an ASP:ImageButton where I want to call a function and pass a string: OnClick="Change_Photo("John")" I am having problems with "". I tried
6
by: Federico | last post by:
Hi, this is what I can do: - Create new solutions using VS.Net ASP.Net - Save the solutions, build the solution, view in browser with the solution still open. But, once I close the solution, I...
0
by: Jitesh | last post by:
I am facing a problem in webservice, I want to know what will be the exact procedure to solve the problem............. What I want to do............ I have a table named order in SQL Server....
27
by: John Salerno | last post by:
Ok, here's a problem I've sort of assigned to myself for fun, but it's turning out to be quite a pain to wrap my mind around. It's from a puzzle game. It will help if you look at this image: ...
8
by: vj | last post by:
Hi all, I want to solve the two equations u*tan(u)=w and u^2 + w^2=V^2, where V is a known constant, and u and w are the two unknowns to be determined. Please can someone suggest me how to...
1
by: arun | last post by:
Query is too complex -------------------------------------------------------------------------------- Hi, I was trying to solve this problem since last two days but couldn't find any solution. ...
17
by: Michael Reichenbach | last post by:
Here is the example code. int main(int argc, char *argv) { string Result; WIN32_FIND_DATA daten; HANDLE h = FindFirstFile(TEXT("c://test"), &daten); system("PAUSE"); return EXIT_SUCCESS; }
2
by: itsvineeth209 | last post by:
My task is to create login control without using login control in tools. I shouldnt use sqldatasource or any other. I should use only data sets, data adapters and data readers etc. U had created...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.