|
You are not missing anything. C++ just ends up calling the C functions anyway. fstream.open() calls fopen() which end up calling CreateFile(). Same sh*t, different pile.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I disagree totally. The benefits include object orientation, type safety, custom inserters and extractors. By your logic, we should all be writing programs in assembly, hell, that's what it all ends up as, right ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In addition to the comments that have been made, iostreams is a powerful framework for passing data to any stream ( the obvious, non file examples are the screen and a string ), and in particular, for writing code to encapsulate how your data is passed. I find it much nicer to write an inserter and extractor for a class, so my main code looks like this
myFile << myObject;
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi
I detect one problem in your code.
you can try it. I am not sure but I think thats the problem.
your code goes like this
...
if(feof(f[x]))
return;
fseek(....);
char v = fgetc(f[x]);
if(x == 0)
fputc(v, outputz);
...
I suggest to put the EOF condition after you read the character.
i.e
fseek(....);
char v = fgetc(f[x]);
if(feof(f[x]))
return;
if(x == 0)
fputc(v, outputz);
Best of luck
Anil
|
|
|
|
|
|
Hi,
I have a project which accesses a database via a database interface class which uses #include <afxdb.h> microsoft library.
In the header file for this database class I have a prototype which passes by reference a CRecordset paramater.
When i add in #include <afxdb.h> in to the header file.
I get the 2872: 'IServiceProvider' : ambiguous symbol
Can anyone help.
To summarise .. I have two files Database.cpp and Database.h. both have to #include <afxdb.h>. When I compile i get the following error. 2872: 'IServiceProvider' : ambiguous symbol.
The class is a general c++ class the compiler is c++ 7.1 and the .net framework is 1.1.
Jerry
|
|
|
|
|
JerryMcguire wrote: I get the 2872: 'IServiceProvider' : ambiguous symbol
Try to use Namespace with the interface while declaring its pointers!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm searching for a solution on reading motherboard serial number using VC++. Can someone give me a hint? Need code.
Tibi
|
|
|
|
|
You do realize that not all motheboards report the serial number in the bios?
John
|
|
|
|
|
Yes, but the motherboards that have a sn can reveal it?
|
|
|
|
|
|
the web-page you given is merely a structure but function,to obtain the concerned information what function I should use ? even though I can get it through that function,but no serial-number is given in the structure .I have
tried to find a way to get the serial number for one of the important device in pc (for instance : main-board cpu hard-disk),but finally I fond out that DiskId is the most suitable one apart from commercial library.
|
|
|
|
|
|
would you make yourself more explicit ?
this web-page doesn't include any stuff about Win32_BIOS,
perhap I am not qualified enough to disgest that article .
thank you so much .
|
|
|
|
|
suchuhui wrote: but no serial-number is given in the structure
string SerialNumber;
suchuhui wrote: fond out that DiskId is the most suitable one apart from commercial library.
I assume you are trying to do some kind of licence / copy protection and generally diskid/macaddress are the things used in this case.
John
|
|
|
|
|
suchuhui wrote: but no serial-number is given in the structure
string SerialNumber;
Is part of the structure.
suchuhui wrote: fond out that DiskId is the most suitable one apart from commercial library.
I assume you are trying to do some kind of licence / copy protection and generally diskid/macaddress are the things used in this case.
John
|
|
|
|
|
have you tried DiskId ?
search in the Internet get the source code,don't use DiskId32.dll,
it cann't run at some of os.I can give you my own code if you want it.
|
|
|
|
|
I tried diskid, it works, but I wanted to find something else. Thanks for all.
|
|
|
|
|
Hello everyone!
Alright... I have this file:
<br />
|............||<br />
...............<br />
...............<br />
...............<br />
...R...........<br />
...............<br />
...............<br />
...............<br />
...............<br />
...............<br />
...............<br />
|.............|<br />
I need to read, for example, character at (4,5) (letter R). How do I do that, in standard C++? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 12:32 Sunday 5th February, 2006
|
|
|
|
|
read the lines one at a time until you get to the required line, then get the required character
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
int row = 0;
int col = 0;
do
{
cout << "Enter line number ";
cin >> row;
cout << "Enter column number ";
cin >> col;
if (row < 1 || col < 1)
return 0;
ifstream ifs(argv[1]);
string str;
int x = 1;
for (x = 1; x <= row && !ifs.eof(); ++x)
ifs >> str;
if (ifs.eof())
cout << "Invalid line" << endl;
else if (col > str.length())
cout << "Invalid column" << endl;
else
cout << str.c_str()[col - 1] << endl;
ifs.close();
} while (1);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote: ifs >> str;
Hmm... I don't get it... Is that suppossed to get a line? Is there a C-style equivalent? I don't want to use C++ style, it makes my EXE like 200 KB bigger! Or is it suppossed to do something else? Much thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
Kixdemp wrote: I don't want to use C++ style
In your original post you asked for standard C++, so that is what I gave you.
Kixdemp wrote: Is that suppossed to get a line?
Yes, The C equivalent is fgets() .
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote: Kixdemp wrote:
I don't want to use C++ style
In your original post you asked for standard C++, so that is what I gave you.
Whoops, sorry, I confused terms...
But I'll try that if what I said in my other post doesn't work... Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
string curLine;<br />
f[x] >> curLine;
That gives out errors, because f[x] is a pointer, look:
ifstream * f[3];<br />
f[0] = new ifstream(string(map + ".ml1").c_str());<br />
f[1] = new ifstream(string(map + ".ml2").c_str());<br />
f[2] = new ifstream(string(map + ".ml3").c_str());
I already tried this:
string curLine;<br />
(ifstream&)f[x] >> curLine;
But that just crashes my app... Is there a correct way to do it? Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
I have written a few applications in VC++ 2003 that access database information via ODBC. The typical application makes various SQL requests and displays the results in a Single Document CListView, using the report style.
The programs seem to execute fine as long as they have complete focus with uninterrupted processing time. If I try to minimize the window or check my Outlook email or use some other application while the database application processes some lengthy data retrievals, the database application hangs up.
Any ideas or suggestions to make the program work more efficiently?
Thanks for any comments!
|
|
|
|