|
Oh man! check your logic. You get input from file in an array. Since you have got all the data from there, file pointer has reached to end of the file. Now when you go in loop, condition is true. So nothing will be printed in output file.
So if you want to get correct output of your code, let us know what exectly you want from your code to do in while loop.
Good luck.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
does your file contains 14 charectors only or more...
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
|
How will the "fin" file ever reach the end when you're only reading from it once! Surely you need to move the fin.getline(str,sizeof(str),'\n'); bit into the while loop.
Steve
|
|
|
|
|
In fact you should get input from data.txt within your loop. As you are not getting input in loop, your file pointer in data.txt in not moving. So there will be infinite loop.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
yeah..how can i stop the loop once i got all the possible shuffling of numbers.
|
|
|
|
|
so did you get your problem solved?
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
yeah thank u..it continues long way more...bcause i ve to end up this with GUI interface....just took a challenge to learn C++ in 2 weeks...till ca MFC part...n i m learning alot..thankz..for who r kind hearted to help!
|
|
|
|
|
makaveli_07 wrote: just took a challenge to learn C++ in 2 weeks
2 weeks... It's a joke, isn't it ?
And, if you really want to learn something, it is not by doing cut and paste without trying to understand that you will learn something. Really, if you want to learn the language, follow my advice: buy yourself a good book and start from the begining (and do the things yourself and THINK by yourself). It's not because you made a program (with the help of people here) that you can program.
Learning a programming language is like learning a new language and also a new way of thinking (if it's the first language that you learn). What will you think if I tell you that I want to learn Japanese in two weeks.
|
|
|
|
|
now everythin is okie but...onli one line of digit output in the file..i need all the possible randomized shuffling..
<code>#include <ctime>
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
using namespace std;
time_t tmStart, tmEnd;
void DoStuff()
{
tmStart = time(0);
ifstream fin("data.txt",ios::in);
ofstream File("MyFile.txt",ios::out);
char str[14];
// fin.getline(str,sizeof(str),'\n');
// string line(str);
//cout << str<<endl;
int i=0;
// while(fin.eof() == NULL )
while(true)
{
if(fin.getline(str,sizeof(str),'\n'))
{
string line(str);
random_shuffle(line.begin(), line.end());
File << "Randomised: " << line << endl;
File << " : " << line << endl;
File << " : " << line << endl;
File << " : " << line << endl;
File << " "<< endl;
// File << "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
File << " "<< endl;
++i;
//continue;
tmEnd = time(0);
cout << tmEnd-tmStart << " seconds " << endl;
}else break;
}
File.close ();
fin.close ();
}
int main(int argc, char* argv[])
{
DoStuff();
return 0;
}
</code>
|
|
|
|
|
I've been very patient and even defended you for asking so many questions in the face of other CPians suggesting that you're not even trying and that in fact all you're really trying to do is get other people to do your work for you. Was I wrong? Look how quickly you ask another question after the never ending loop problem was solved for you. It seems impossible that you’ve given the problem any serious thought.
Steve
|
|
|
|
|
Stephen Hewitt wrote: I've been very patient
That's for sure
I gave up when I posted code that he was even not capable of simply copying
|
|
|
|
|
The Microsoft Most Valuable Professional (MVP) Program recognizes and thanks outstanding members of technical communities for their community participation and willingness to help others. The program celebrates the most active community members from around the world who provide invaluable online and offline expertise that enriches the community experience and makes a difference in technical communities featuring Microsoft products.
I've been asked by Microsoft to nominate North American Visual C++ developers deserving of Microsoft MVP status. Please make your nominations here or email me at webmaster@codeproject.com.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Chris, I know you are really busy, did you consider offshoring this effort?
Sorry couldn't resist.
led mike
|
|
|
|
|
|
Trollslayer wrote: MVPD (Most Valued Prima Donna)?
Maxwell Chen
|
|
|
|
|
The problem is there's only a limited number they can take.
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Did you perhaps mean VAIN -- Most Vain Prima Dona
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
I am working on a school project to find the volume of a wine goblet. Does anyone have c++ code for solids of revolution such as rotation of a curve around an axis? Something basic like a sin wave? I can then work on altering the code to find the rotated volume of my wine goblet.
Thanks in advance.
John
|
|
|
|
|
You can do this with a variant of integration. I remember doing it at uni but I forget the details. The idea is similar to integration where you find the area under a curve by subdividing it into n rectangles and adding the area of each then find the limit as n approaches infinity. With the volume of rotation of a 2D curve around the x-axis (which produces a 3D solid) you use a similar process except instead of rectangles you use discs (like coins) with the height of the curve at a given point being the radius and the thickness being the length of the interval divided by n.
Steve
|
|
|
|
|
I'm trying to add a custom build step to my project. I want to xcopy a directory structure to my output directory
e.g. something like
xcopy $(ProjectDir)\foo $(ProjectDir)\$(Outdir)\foo
It works, but it copies it on every build. I only want it copied if something under foo has changed (new file added, file changed, etc...).
Actually, I wouldn't really mind having it copied on every build, except that whenever I try to run my app from vc++, it complains that the project is out of date and asks me to rebuild.
The custom build step forces me to specify an output file, so it can check the timestamp to see if it needs to be updated - not really sure what to put here, since I'm copying a whole directory structure. I tried a few different things, but it made no difference.
Anyone know an easy way to do this?
|
|
|
|
|
If you use batch commands you can do what you want to do.
/M of "xcopy" copies only files with the archive attribute set, and turns off the archive attribute.
/A of "xcopy" copies only files with the archive attribute set, and doesn't change the attribute
You can set the archive attribute using "attrib".
-- modified at 23:23 Thursday 4th May, 2006
|
|
|
|
|
Thanks George... I got the copying working alright now. What I needed was the /D option (copies files where the src version is newer than the destination version).
However, I still have the problem that VC++ thinks my project is out of date each time I run my program... it only happens for the Debug configuration (whose Custom Build Step is identical to the Release configuration).
I have:
Command Line
xcopy /S /Y /I /D "$(ProjectDir)Template" "$(ProjectDir)$(Outdir)\Template"
Outputs:
"$(ProjectDir)$(Outdir)\Template"
What can I do to make it so that VC++ doesn't think my project is out of date?
|
|
|
|
|
I used the Build Events of the Project and only copied files that don't normally get copied:
XCOPY /D/Y "$(ProjectDir)Test.x*" "$(TargetDir)" && XCOPY /D/Y "$(ProjectDir)Test.txt" "$(TargetDir)"
There is no Outputs property by the way.
|
|
|
|
|