|
Hello.
This seems to be a console app. If it is, them you can just redirect it's output to the file you want.
An example: Suppose your programs name is Program.
Start a command/DOS prompt and go to the directory of the program.
Run your program like this:
Program >outfile.txt
Now you have got a file named outfile.txt
It contains the output of your program.
|
|
|
|
|
Yes, but everything will be redirected to the file. The question for the number of digits also.
|
|
|
|
|
That's right.
I missed that part.
|
|
|
|
|
i ve to include dis in da source code...n i m using visual c++..can u help me..
|
|
|
|
|
In your DoStuff function, open a file stream and output the data the same way you do now (except in the file stream):
ofstream File("MyFile.txt");
File<<Randomised: "<<s<<endl;
Don't forget to include <fstream> at the top of your file (and don't remove the using namespace std line neither).
|
|
|
|
|
i cant get it...can u pls show where to use it..in ma program i sent der..n past it back...
|
|
|
|
|
I just told you: in the DoStuff function. Open this stream at the top of your function and replace all the cout<< by File<<
BTW: when you post code, don't forget to use the code or pre tags just above the emoticons.
|
|
|
|
|
still cant get is dis correct....
<br />
#include <iostream><br />
#include <string><br />
#include <algorithm><br />
using namespace std;<br />
<br />
ofstream File("MyFile.txt");<br />
void DoStuff()<br />
<br />
<br />
{<br />
file << "Enter digit: ";<br />
string s;<br />
cin >> s;<br />
file << endl;<br />
<br />
for (int i=0; i<500; ++i)<br />
{<br />
random_shuffle(s.begin(), s.end());<br />
file << "Randomised: " << s << endl;<br />
file << " : " << s << endl;<br />
file << " : " << s << endl;<br />
file << " : " << s << endl;<br />
file << " "<< endl;<br />
<br />
file << "Single Row: " << s << " " << s << " " << s <<" " << s << endl;<br />
file << " "<< endl;<br />
file << " "<< endl;<br />
file << " "<< endl;<br />
file << " "<< endl;<br />
<br />
<br />
<br />
} <br />
<br />
<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
DoStuff();<br />
return 0;<br />
}<br />
|
|
|
|
|
I suggest you read some good book about C++. It seems that you are lacking some of the fundamental syntax. I don't say that to be mean but it is a suggestion.
Now, for the code: when I say in the function that means inside the function, not outside :
void DoStuff()
{
ofstream File("MyFile.txt");
And if you declared the variable as File , use it with the same name (not as file ):
void DoStuff()
{
ofstream File("MyFile.txt");
cout<< "Enter digit: ";
string s;
cin >> s;
cout<< endl;
for (int i=0; i<500; ++i)
{
random_shuffle(s.begin(), s.end());
File<< "Randomised: " << s << endl;
File<< " : " << s << endl;
File<< " : " << s << endl;
File<< " : " << s << endl;
File<< " "<< endl;
File<< "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
File<< " "<< endl;
File<< " "<< endl;
File<< " "<< endl;
File<< " "<< endl;
}
}
And of course, if you replace the firsts cout with File, the question (asking the user to enter the number of digits) will also be redirected to the file. That looks logical no ?
|
|
|
|
|
still gt many error...try to run it in ur machine...
<code><
#include <iostream>
#include <string>
#include <algorithm>
#include<fstream.h>
#include<conio.h>
using namespace std;
void DoStuff()
{
ofstream File("MyFile.txt");
// Get the input from the user.
cout << "Enter digit: ";
string s;
cin >> s;
cout << endl;
for (int i=0; i<500; ++i)
{
random_shuffle(s.begin(), s.end());
file << "Randomised: " << s << endl;
file << " : " << s << endl;
file << " : " << s << endl;
file << " : " << s << endl;
file << " "<< endl;
file << "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
file << " "<< endl;
file << " "<< endl;
file << " "<< endl;
file << " "<< endl;
}
}
int main(int argc, char* argv[])
{
DoStuff();
return 0;
}
/code>
|
|
|
|
|
Are you kidding ??
Can't you read what I posted ??? I also posted code. Can't you simply look at it and compare it with your own code ?
Replace file by File (everywhere). C++ is case-sensitive, so that means File and file are two different variables.
|
|
|
|
|
He's not interested in helping himself, so don't bother helping him.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
if u cant help..dun discourage others...this forum is to get help n help others...nt to give useless speech...
|
|
|
|
|
makaveli_07 wrote: this forum is to get help n help others
sure, but you don't have to think that someone will do the whole job for you. you have to work by yourself first, and ask for specific questions when you cannot go further on a point.
here, it's obvious that you don't really understand what you do (first because you don't seem to know C++, and because the VC++ compiler error messages are clear enough to let a beginner understand what he made wrong - still, at the condition that he knows C++).
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
He explained exactly what you had to do. If you had bothered to follow it, you would have got your code working immediately. You posted back more code that didn't work that didn't incorporate any of the changes that he suggested to you. If you ask a question, read the answers.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
thank u brother i got it...
|
|
|
|
|
|
he is kewl man...sorry if i m annoying...its just few days i started to learn c++...
|
|
|
|
|
Its okay that any exe can be made to startup automatically.
But i want to build a windows service with no GUI and only works in background and i should be able to control it with windows service manager. I found so many atricles to do it in .NET but can anyone help me to do it in VC++ 6.0???
For eg. a timer that works in background and displays a messagebox every 1 minutes.
Please help me. I am in daaaaaaaaam need of help.
|
|
|
|
|
hi,
refer the Book called "Server Side Programming" by Jeffery Ritcherd.
He has neatly mentiod about the Windows Serviceses in Chapter2 and Chapter3.
which will neatly guide you.
cheers.
uday.
uday kiran
|
|
|
|
|
Hello,
How to find hex pattrens (hex strings ) in binary file
and save all found pattrens in aonother file . If
i want to find pattren ee ed ef e0 in binary file
and also want to find how many times this pattren accurs
andwant to save its all positions in binary file this
pattren occurs.
|
|
|
|
|
Well have you tried fscanf .
Nibu thomas
Software Developer
|
|
|
|
|
i think fscanf does not work in this case . I want to
search hex valuse as most hex editor do .
|
|
|
|
|
I have a pretranslate function wherein im checking for a key i/p "Ctrl+Tab" for which I use:if (pMsg->wParam == VK_TAB && GetKeyState(VK_CONTROL) < 0)
which works fine.
But then I display a msgbox and moveon to TranslateMessage to find that no longer is the keystate for 'tab' valid, its replaced by 'enter'. However, if i dismiss msgbox using tab+enter i find the 'tab' keystate retains.
GetKeyState is supposed to read key-state at the time of msg i/p, then how does one explain this behaviour. Could someone explain the working of GetKeyState and how do i rectify the problem?
|
|
|
|
|
i am using Microsoft TAPI implimentation of H.233, i wanted to place the call on hold/resume and Transfer the call. The error i get is this implimentation does not take advice. Can anyone please help .
Thanks in Advance
Sanju
|
|
|
|