473,509 Members | 6,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1567

"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
12776
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
1838
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
1996
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
2478
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
1320
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
2275
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
4792
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
2647
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
4072
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
2362
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
7137
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...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.