|
Your welcome. And being a Monday I surely could use the hug.
John
|
|
|
|
|
Hi!,
I am developing a container for embedding Miscosoft Word documents.
I am using CoCreateInstance()to create object,
after creation I set the clientsite and with the help of IPersistInterface::Load I load the storage, at this moment a temporary file having extension .doc is created in the Temp folder.
I want to avoid the creation of the temporary .doc file in the Temp folder.
and I also want to know the reason as to why the temporary .doc file is created.
Thanks
Anshuman
|
|
|
|
|
Probably Word creating it for its own purposes, for example to keep a working copy on disk for auto-recovery. You can't do anything about it, don't worry about it.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I have a file that contains the following datas:
-2363824.109 (x position)
4870666.240 (y position)
2.18 (speed)
I want to read from this file either just the x position, either the y position, either the speed.
I did the following:
int main(int argc, char *argv[]){<br />
<br />
ifstream GPSFile;
GPSFile.open("C:\\My Files\\GPSFile\\GPSFile.txt", ios::in);
double CataCoordX, CataCoordY;<br />
double gpsx=0, gpsy=0;<br />
while (!GPSFile.eof()){
if (GPSFile.rdstate() == ios::failbit){cout<<"ERROR, \n";}<br />
GPSFile >> gpsx;
GPSFile >> gpsy;
CataCoordX=gpsx;
CataCoordY=gpsy;
}
cout << CataCoordX <<endl;<br />
cout << CataCoordY <<endl;<br />
GPSFile.close();<br />
return 0;<br />
}
This will print :
2.18
4.87067e+006
But me i want to print the first and the secon value. How to do this?
THX
|
|
|
|
|
YOU HAVE GOT A PROBLEM IN THE while LOOP.
I have stripped down ur while loop for simplicity;)
The Problem(step by step):
while (!GPSFile.eof()){<br />
GPSFile >> gpsx;<br />
GPSFile >> gpsy;<br />
}
In the first time it loops, x-value is copied into gpsx and y-value is copied into gpsy. BUT you havent reached end of file yet, SO the while loop is executed again and this time, the value of speed is copied into gspx (thats the ERROR!!!)
So erronous output is
2.8
4.87067e+006
SOLUTION
Solution 1:
while (!GPSFile.eof()){<br />
if (GPSFile.rdstate() == ios::failbit){cout<<"ERROR, \n";}<br />
GPSFile >> gpsx;<br />
GPSFile >> gpsy;<br />
break; :rose:<br />
}
CataCoordX=gpsx;<br />
CataCoordY=gpsy;
Solution 2:
while (!GPSFile.eof()){<br />
if (GPSFile.rdstate() == ios::failbit){cout<<"ERROR, \n";}<br />
GPSFile >> gpsx;<br />
GPSFile >> gpsy;<br />
GPSFile >> gpspeed;
CataCoordX=gpsx;<br />
CataCoordY=gpsy;<br />
}
PROBLEM SOLVED
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
...avenger
|
|
|
|
|
Thx a lot, I really thought i will get no answer to my silly queston.
Though is there a method that will allow me to read no matter what line of the text file, without being obliged to read all the file? I mean like positioning the "cursor" to a certain position and read from there?
What I mean is if I have a bigger file as:
-2363824.109 (x position)
4870666.240 (y position)
2.18 (speed)
4566888.0035 (z position)
58.6544 (something)
269.2 (something)
And i if i want to retrieve for example the 3rd line. Is there a simple solution?
THX
|
|
|
|
|
First of all tell me one thing: do you need answers in terms of the "<<" operator or you just want an elegent solution?
There is much better and elegent solution if you dont use "<<" technique.
Do you want the alternate technique or some modifications using "<<" ?
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
i used here "<< " just to visualise things better, but if u have a better idea say it to me please
THX
|
|
|
|
|
See, the best way (that i feel) of reading and writing srtuctured data to a file is using the following functions:
istream::read
ostream::write
Function prototypes are: read( const unsigned char* ptr, int n)
Description: The read function reads n characters starting form the location pointed to by ptr. In other words, read function reads n bytes from the address pointed to by ptr.
The write has similar prototype and similar description (but used to write data)
The above functions work best for reading/writing classes and structures from/to files.
EXAMPLE:I include all your data in a class, say "A"
class A<br />
{<br />
double x;<br />
double y;<br />
double speed;<br />
double z;<br />
int something1;<br />
char something2;<br />
};
Then i write all these this to a file using the code:
main()<br />
{<br />
A objectA;<br />
cin>>objectA.x;<br />
cin>>objectA.y;<br />
cin>>objectA.z;
<br />
ofstream outfile ("c:\\test.txt", ios::binary);<br />
outfile.write ((char*)objectA, sizeof(objectA)); <br />
}
Once the object has been written into a file, you can read it anytime using using the code:
main()<br />
{<br />
A objectB;<br />
ifstream infile ("c:\\test.txt", ios::binary);<br />
infile.read ((char*)objectB, sizeof(objectB)); <br />
cout<<objectA.x;<br />
cout<<objectA.y;<br />
cout<<objectA.z;
}
YOU CAN CALL WRITE AGAIN AND AGAIN TO APPEND MORE TAHN ONE RECORDS INTO THE FILE
SIMILAR IS THE READ FUNCTION. WHEN U CALL READ AGAIN, IT WILL READ THE NEXT OBJECT WRITTEN INTO THE FILE.
All this may appear a bit fuzzy and complicated to you, BUT TRUST ME, this is the best way to handle structured data in files in C++.
Ask if u have any doubts;)
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Ok I like this idea. I will try to use it. Could i, in case i want more details contact u on ur private mail?
THX
|
|
|
|
|
If u follow the above mentioned technique, u can display any field, any time. Also u dont have to mess with the seek stuff. Thats very unreliable.
You can personally contact me at avenger_sb25@yahoo.com or at avenger_sb25@hotmail.com
I daily check both these mails.
If u want, u can add me to your Yahoo Messenger or MSN Messenger
...cya
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
You could if each line were the same length, or each xpos/ypos/speed group was the same size. The seekg() method is used to position the file pointer for the next read operation.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
First thx for friday.
Then what do u mean by the same length? Is space or tab considered as getting in the value's lenth? Or just by adding zeros at the end?
I looked in a tutorial for the skeeg stuff and didn't understand well how it works. Could u breif me about this, please?
THX
|
|
|
|
|
dairiseky wrote:
Is space or tab considered as getting in the value's lenth?
Yes, just because the character is not printable does not make it any less of a character.
The seekg() method goes to a certain position within the file. It knows nothing of line-length. So if you had a two-line file, with the first line being 5 characters and the second line being 15 characters, seekg(6) would go to the start of the second line, but if the length of the first line ever changed, it wouldn't. Understand?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
OK thx. Got the trick ! sorry for the deformation of skeeg I was in a rush to get the train.
|
|
|
|
|
OK thx. Got the trick ! sorry for the deformation of skeeg I was in a rush to get the train.
|
|
|
|
|
Is it possible to get the size of datas to be written to file and then use this (their size), to be able to retrieve the right data?
THX
|
|
|
|
|
Yes. Wasn't that answered here?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Dear Friends,
I want to perform certain operation when the dialog "just appears" on screen. I dont want to perform this operation in OnInitDialog(), because at that time dialog is not appeared on the screen.
Which message is get posted when it is ensured that dialog is just diaplayed on the screen ?? Or is there any other way ?
Imtiaz
|
|
|
|
|
Well, I can think of one possible solution:
Whenever the windows is dispayed (for the first time too) it definitely receives a WM_PAINT message.
You can use the following trick:
<br />
static int i=0;
OnWmPaint()<br />
{<br />
if(i==0)<br />
{<br />
_____(LINE1)<br />
i++;<br />
}<br />
else<br />
{<br />
}<br />
}
Now, if you want to execute LINE1 whenever window is displayed, reset the value of 'i' to 0 when you hide or close the dialog box.
NOTE:Don't worry, you can intercept WM_PAINT message even for a dialog boxI hope this trick will solve your purpose.
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Imtiaz Murtaza wrote:
Or is there any other way ?
Use PostMessage() at the end of OnInitDialog() . This allows the function to return so that the message pump gets started, and the dialog gets rendered. At that point, your message handler should get called.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,
Can anyone pls provide me in getting some useful sites for preparing for
C++/VC++ interview.SSites which have some code snippets or examples.
Pls help.
Ram
|
|
|
|
|
And this is going to help how, exactly?
CP is full of examples and wise comments about VC++ and C++ generally, but that won't help in an interview unless the people doing the interview are looking for (or expecting) someone who doesn't have real-world experience.
I'm familiar with the 'how do you get experience if you can't get a job' paradox. Me, I got lucky, but I've heard of cases where people lied outright about their experience and were stupid enough to believe they'd be able to bluff it until they knew enough. In those same cases, they tended not to last long.
And before anyone leaps on their high horse to say how dare I suggest that Ram is going to lie in an interview, I'm not suggesting anything of the kind, it's merely an aside about what happens if you try and beat the 'experience' system.
Steve S
|
|
|
|
|
Steve S wrote:
I've heard of cases where people lied outright about their experience and were stupid enough to believe they'd be able to bluff it until they knew enough. In those same cases, they tended not to last long
Cough Cough....3 years...Cough Cough...
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Well, always remember this thing- In interviews covering C/C++ the main focus is on concepts and techniques not how many programs you have made or how big are the programs u hav made.
Focus on the following topics-
1. Pointers (HOTTEST TOPIC with raw C++ ,esp. "Function Pointers", Pointer to arrays etc.)
2. Threads (Common topic with VC++)
3. Message Queues Architecture (VC++)
4. There r lot of books on "objective/practice questions in C++/VC++". Pick any of them and go through them
Rest is up 2 ur effort;)
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|