|
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
|
|
|
|
|
can u please give the links on TAPI.
|
|
|
|
|
HI All
when we right click on any file or folder then a popup menu display, what I want is to enter my application name in that pop up menu, so that when any user right click on any file or folder then he should have option to start application for that file or folder.
Pleae guide me that how to perform this.
better if provide some article or code snippet.
Thanks in advance
|
|
|
|
|
You have to write shell extensions for this purpose. Search CP with the keyword Shell Extensions.
Nibu thomas
Software Developer
|
|
|
|
|
i need a help where the program must give a with a randomizing number...a number must repeat 4 times da same 13 digits then bring it to straight line by lefting space in between...
for example:
digit entered 0123456789123
randomized as:
1234567890123
1234567890123
1234567890123
1234567890123
bring to straight line:
1234567890123 1234567890123 1234567890123 1234567890123
and then continue the same thing with other randomized number..
-----------------------------------------------------------------------------
This is the code i ve done..pls help me with this..
#include <iostream.h>
int i;
void createArithmeticSeq();
void matricize(int number[], const aa);
void reverseDiagonal(int number2d[][4], const aa);
void main()
{
createArithmeticSeq();//go to sequence function
}
void createArithmeticSeq()
{
const aa = 15;
int number[aa];
i=0;
int num,diff;
cout<<"Enter a digit:"<<endl;
="" cin="">>num;
cout<<"Enter the difference:"<<endl;
="" cin="">>diff;
number[i]=num;
cout<<"the sequence is:"<<endl;
creating="" the="" sequence="" for="" numbers="" and="" diffrence
="" while(i<aa)
="" {
="" i++;
="" number[i]="number[i-1]+diff;
" cout<<number[i]<<"="" ";
="" }
="" cout<<endl;
="" matricize(number,="" aa);="" this="" goes="" to="" matrice="" function
=""
}
void="" matricize(int="" number[],="" const="" aa)
{
="" int="" j="0;
" k="0;
" c1="4;
" c2="4;
" number2d[c1][c2];
="" i="0;
" cout<<"the="" number="" of="" is="" 2="" dimensional="" array="" is:="" "<<endl;
="" converting="" from="" 1="" 2dimensional
="" number2d[0][0]="number[0];
"
="" if(j="">2)
{
i++;
k++;
j=0;
number2d[j][k]=number[i];
cout<<endl;
}
="" else
="" {
="" i++;
="" j++;
="" number2d[j][k]="number[i];
" cout<<number2d[j][k]<<"="" ";
=""
="" }
cout<<endl;
="" reversediagonal(number2d,aa);="" this="" is="" reversediagonal="" function
}
void="" reversediagonal(int="" number2d[][4],="" const="" aa)
{
="" int="" temp;
="" j="0;
" k="0;
//reversing" the="" numbers="" from="" left="" to="" right="" diagonal
="" temp="number2d[0][0];
" number2d[0][0]="number2d[3][3];
" number2d[3][3]="temp;
" number2d[1][1]="number2d[2][2];
" number2d[2][2]="temp;
//reversing" number="" number2d[3][0]="number2d[0][3];
" number2d[0][3]="temp;
" number2d[2][1]="number2d[1][2];
" number2d[1][2]="temp;
" cout<<"the="" sequence="" in="" 2-dimensional="" array="" after="" reverse="" diagonal="" :"<<endl;
="" while(i<aa)
="" if(j="">2)
{
k++;
j=0;
cout<
|
|
|
|
|
I don't get it. Can you explain in more detail?
Steve
|
|
|
|
|
the screen must be like dis:
Enter 13 digit number: 1234567890123 //let say user enter this number
randomized to: 0123456789123
0123456789123
0123456789123
0123456789123 //the randomized numbers must diplay in four rows...the same ranomized number
show in one row: 0123456789123 0123456789123 0123456789123 0123456789123
//the result must be shown in one row...
//then continue wuth next randomized number from the same 13 digits entered
next randomized number : 3456789012123
3456789012123
3456789012123
3456789012123
show in one row: 3456789012123 3456789012123 3456789012123 3456789012123
//repeat the same task.
|
|
|
|
|
I'm still not sure what you mean but this might help:
-----
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void DoStuff()
{
// Get the input from the user.
cout << "Enter string: ";
string s;
cin >> s;
cout << endl;
for (int i=0; i<10; ++i)
{
random_shuffle(s.begin(), s.end());
cout << "Randomised: " << s << endl;
}
}
int main(int argc, char* argv[])
{
DoStuff();
return 0;
}
Steve
|
|
|
|
|
thank u...but i still cant get it..anyway it help me a little..
|
|
|
|