|
hi
I am using an openGL with C
i am unsure on how to write to a console window using this useless programming language
any help would be appreciated
thanks
boyindie
|
|
|
|
|
puts()?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
boyindie wrote: useless programming language
The useless programming language that's been used to
write many operating systems, countless applications,...
I think it's been pretty useful for quite a long time!
Of course, it's all about C# and VB.NET now.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Of course, it's all about C# and VB.NET now.
Fortunately, not for everything!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
George L. Jackson wrote: Fortunately, not for everything!
Heh. Why the :sniff:? I smile about that!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You're right, I should be happy.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
ROTFL - it's the language, and not the person who can't even work out where to post his question, that is the problem...
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Any idea how OS know that it has lost power and running from UPS.
|
|
|
|
|
If you read the first thread in this forum you should be able to determine that your question is not appropriate to this forum.
|
|
|
|
|
i have created a windows application but i am facing some problem when its looses power so i need to shutdown computer as soon as it looses power and switch to different power source. just cant figure out how i would get this information.
Thanks
|
|
|
|
|
|
In the hardware (or the OS/SysAdmin) forum my answer would be:
Some UPS provide a serial/USB connection to inform PC about a power outage.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hello everybody
I would like to get the sorcecode of the fxcop. i want to customize fxcop.
so please help me to know where can i get the source code of fxcop from.
bhaskarsri
|
|
|
|
|
If you read the first thread in this forum you should be able to determine that your question is not appropriate to this forum.
|
|
|
|
|
what is advantage of "Base class pointer to Derived Class object" ?
class Base
{
public:
Base(){ cout<<"Constructor: Base"<<endl;}
~base(){="" cout<<"destructor="" :="" base"<<endl;}
="" void="" funbase()
="" {
="" cout="" <<"base="" function="" invoked"<<endl;
="" }
};
class="" derived:="" public="" base
{
="" public:
="" derived(){="" cout<<"constructor:="" derived"<<endl;}
="" ~derived(){="" funderived()
="" <<"derived="" }
};
int="" _tmain(int="" argc,="" _tchar*="" argv[])
{
="" cout<<"ashish"<<"\n";
="" base="" *var="new" derived();
="" delete="" var;
}
even="" though="" "var"="" points="" to="" derived="" class="" object="" ,="" it="" cannot="" access="" member="" i.e="" funderived().="" var="" can="" only="" functions.
instead="" of="" why="" dont="" we="" use="" ,
=""
="" *check="new" base();
="" check-="">fun1();
I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object?
Thanks\
Ash.
|
|
|
|
|
In this instance, none. However, if you have many different derived classes, you can create a collection of the base class to hold them all, and if the base class defines a generic interface, an instance of the base class can do many things, depending on what derived class the instance is.
This question is in the wrong forum, BTW. This is for .NET questions only.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I need to be able to control the position of where I need to read/write a file. I tried fileStream->Position = 0, streamReader->BaseStream->Position = 0, fileStream->Seek(0, SeekOrigin::Begin), streamReader->BaseStream->Seek(0, SeekOrigin::Begin). None of these appear to work. How do I go about doing this?
Thanks
Buck
|
|
|
|
|
streamReader->BaseStream->CanSeek is true?
If not, I guess Seek and Position should throw exceptions.
How are they not appearing to work?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a file that I am using unique "Header" lines. In order to determine if all the headers are present I use String^ fileContents = streamReader->ReadToEnd(), then fileContents->Contains(uniqe_search_string). Then I try to reposition the file to the begining in order to read from the begining of the file until the end of the file is reached with...
while(streamReader->Peek() >= 0) { streamReader->ReadLine(); }
It's in the Peek() function. If I don't ReadToEnd(), then ReadLine() three times and then Position = 0, then I can WriteLine at the begining of the file. It would seem that once the Peek() function has reached the end of file that the stream needs to be closed and then reopened for the Peek() function to be cleared. I'll play with this a while to see if I can make it work the way I want.
Buck
|
|
|
|
|
I see two options to fix this....
BuckBrown wrote: while(streamReader-> Peek() >= 0) { streamReader->ReadLine(); }
1) You can replace the above line with
while(streamReader->ReadLine())
2) You can change the above line to these two lines
streamReader->DiscardBufferedData();
while(streamReader-> Peek() >= 0) { streamReader->ReadLine(); }
Mark
*edit* freakin smilies
Last modified: 15mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
This has been exhibiting some real strange behavoir. I have seen my output begin writing at position 0 as it should after a fileStream->Position = 0, and then I have seen it begin writing at approximately position 100 (when I designated position 0). As I try to debug this problem something seems to "magically" change where position 0 actually is and will stay that way for half an hour and then change to some other position when I designate position 0. If I start with no file existing then the file is created and the following written into it...
[Line Test]
[OVP Test]
[SCP Test]
[UVLO Test]
After that I...
fileStream->Position = 0;
for(int index = 0; index < 3; index++)
{
string = streamReader->ReadLine();
streamWriter->WriteLine(string + "X"); // Notice the appended X
}
And the output looks like...
[Line Test]
[OVP Test]
[SCP Test]
[UVLO Test]
[Line Test]X
[OVP Test]X
[SCP Test]X
[UVLO Test]X
Which is not what I was expecting. Change the above code by one line to set the position to the begining of the file before each streamWriter->WriteLine() to get the code below...
fileStream->Position = 0;
for(int index = 0; index < 3; index++)
{
string = streamReader->ReadLine();
fileStream->Position = 0; // fileStream->Seek(0, SeekOrigin::Begin); behaves the same.
streamWriter->WriteLine(string + "X"); // Notice the appended X
}
And I get the ouput I want, but not what was expected (I expected one line in the file "[UVLO Test]X"). The output file now looks like this...
[Line Test]X
[OVP Test]X
[SCP Test]X
[UVLO Test]X
I don't understand why the file position is not being set the way I would expect it.
Thanks
Buck
|
|
|
|
|
Are both the streamreader and streamwriter using the same stream? Or a separate stream to/from the same file?
If so...
Results are going to be really unpredictable.
You may be getting lucky because the reader has buffered the entire file before you do any writing.
You can't expect to read and write to the same file at the same time, at least not at overlapping locations.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Is your 'if so...' pertaining to the first case or the second case? I am setting up my file as follows...
fileStream = gcnew FileStream(stringPath, FileMode::Open, FileAccess::ReadWrite);
streamWriter = gcnew StreamWriter(fileStream);
streamReader = gcnew StreamReader(fileStream);
Buck
|
|
|
|
|
BuckBrown wrote: Is your 'if so...' pertaining to the first case or the second case?
Both, actually
After posting I thought about how you were getting those results
and figured you HAD to be using a common stream.
That's not going to work, at least (especially) not in a read and write loop
like you're doing.
There's two pointers each for both the reader and the writer involved here.
One is the stream position, which you have control of.
The other is the reader and writer's internal buffer pointer, which you don't
have control of.
In your first example, first iteration of the loop...
You request to read a line. For efficiency, the reader reads an
entire buffer full (or the entire file, whichever is smaller).
In this case, it looks like the entire file is buffered so the stream pointer
now points to the end of file. All reads come from the readers buffer, all
writes now go to the end of the file, since that's where the stream pointer
was at the point of the first write. I hope that makes sense.
Now let's say you manage to control all of this (using unbuffered I/O and random
access (seeking) to the stream). If you read a string, add a 'X', write it back
to the file, and then try to read the next string, your 'X' will have overwritten the
next string in the file, unless you shift the remaining bytes in the file "to the right"
to make room for the 'X'.
This is why reading and writing each iteration of the loop is not going to work.
You need to do all the reading in one loop, make appropriate changes, then write
the results back to the stream. Sharing the stream like you're doing is fine - just set the
stream position back to the appropriate place before starting the write loop.
Of course, if there's data in the file beyond what you've read, that would all have to be
shifted to make room for anything you add.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|