|
Sounds lovely . What a pity, that Boston is toooo far from Prague...
Robert-Antonio
"I launched Norton Commander and saw, drive C: on the left, drive C: on the right...
Damn, why I need two drives C:??? So I formatted one..."
|
|
|
|
|
Hey, for that kind of offer, the trip seems worth it...
Steve S
|
|
|
|
|
ok, so i got a book on C++, cuz i figure that i need to learn a new lang. VB is ok, but i want to learn new stuff..
anyway, i think this book is for c++6, and i got c++.net2k3
so i am writing the first couple of lessons, basic io stuff, and it doesn't work like its supposed to. lemme show ya:
------------------------------------------
<br />
<br />
#include <iostream> <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
main (void) <br />
{ <br />
iostream::cout << "What is your age?" << endl; <br />
iostream::cin >> Age >> endl; <br />
iostream::cout << "What is your Character Type?" << endl; <br />
iostream::cin >> CharacterType >> endl; <br />
iostream::cout << "What is your character's description?" << endl; <br />
iostream::cin >> CharacterDescription >> endl; <br />
<br />
iostream::cout << "Your character's age is " << Age << " , character type is " << CharacterType << " , and your character's description is " << CharacterDescription << " <br />
<br />
return 0; <br />
} <br />
-------------------------------------------
so then when i run it, and it asks my age, and i put in 28, it assigns 2 to Age, 8 to CharacterType, and looks like this <its in="" dos="" console="" mode,="" i've="" tried="" both="" win32="" app,="" and="" .net="" app="">:
----------------------------
What is your age? 28
What is your Character Type? What is your Character's Description? Blue
Your character's age is 2 , character type is 8 , and your character's description is b
----------------------------
i did everything just as it is in the book, and when i look at the variables, they say they are supposed to handle more than just one character, but the prog is only taking the one character.
What the...?? <shakes head=""> can some c++.net guru gimme a little help here?
thanks.
Just one a few seconds more, that's all I need. Close a door here, open a new one there, slip a bit of code off to the side to confuse the trail. The logout port is ahead... --«§øùl Ëס§†ëñçê»
|
|
|
|
|
SoulExistence wrote:
main (void)
This is C. I believe that you get the int return type by default, but it should look like this:
int main()
SoulExistence wrote:
iostream::cout
This is bizarre. You need to #include iostream (is that what you did above), and NOT iostream.h ( I can't tell, you didn't check 'don't treat <'s as HTML tags ). Then cout and cin are in namespace std. There is no namespace iostream. Put using std::cout at the top, and then you can just use cout with no namespace qualification. You also need to put a using for std::cin and std::endl.
SoulExistence wrote:
anyway, i think this book is for c++6, and i got c++.net2k3
That only means that if any code in the book does not compile, it is not correct C++. You have the better compiler, but it's unlikely that you'll find any differences for some time.
SoulExistence wrote:
but the prog is only taking the one character.
SoulExistence wrote:
char CharacterType
A char is one character. A string is more than one. And to use strings you need to #include <string>
and put using std::string at the top. The extra include you mentioned was almost certainly stdafx.h, this include MUST be before all the others, but you can ( and I do ) put your standard library #includes and using std::whatever stuff in stdafx.h, so it's visible everywhere.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
/* there's some other include that .net puts in there that i don't know what its for, but its a #include "stdafx.h" */
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
// global variables are evil, although they are forgivable at this stage of learning, remember that variables belong in classes.
int Age, Type;
string Description;
/*the variables byte Age, char CharacterType, and string CharacterDescription are set up here */
int main ()
{
cout << "What is your age?" << endl;
cin >> Age; // Putting endl here is ridiculous
cout << "What is your Character Type?" << endl;
cin >> Type;
cout << "What is your character's description?" << endl;
cin >> Description; // Note that cin will stop on a space. You need to use getline if you want to accept spaces in your string, otherwise "Fred Smith" will only get 'Fred'.
cout << "Your character's age is " << Age << " , character type is " << Type << " , and your character's description is " << Description << endl;
return 0;
}
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
oh, thank you. that is soooo much help.
C++ is a lot diff than VB6, and VB.net is kickin my butt, too. quite the learning curve.
Just a few seconds more, that's all I need. Close a door here, open a new one there, slip a bit of code off to the side to confuse the trail. The logout port is ahead... --«§øùl Ëס§†ëñçê»
|
|
|
|
|
No worries - glad to help. It is a big step to C++ from VB. I'd recommend C# over VB.Net, because that's where Microsoft's focus is going to be in the future.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi.
I wonder if there is any way to backup my registry using straight C++ 6 code or vb6 code. (I am using win 2000).
Ths.
|
|
|
|
|
Check out the Win32 registry API (RegEnumKeys, etc.) It's ugly, but will get you going. Note that if you are on Windows NT, 2000, or XP, you will have to be administrator to be able to read some of the keys.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Backing Up My registry using these Api functions is . I need something really simple.
|
|
|
|
|
To back up the whole registry, use the Windows NT Backup tool (Ntbackup.exe) and use the option to back up the registry. Or, run the rdisk /s command.
check msdn for details...
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
See RegSaveKey() in MSDN.
Respectfully, Igor.
|
|
|
|
|
Ths. This is very useful.
Anton.
|
|
|
|
|
Actually after i red about it, it is much less useful.
SaveKey/Restore Key save the Key Contents, but not the key itself neither its security and other attributes. .
Only Absolute Power and Absolutely No power matters. The rest is slavery.
|
|
|
|
|
When I execute these commands at the DOS prompt, they work just fine - i.e., a file called version.h is created. The file contains the line #define Major 4 .
C:\> set arg=4.5.2-RC8
C:\> for /f "delims=.- tokens=1" %i in ("%arg%") do @set major=%i
C:\> echo #define Major %major% > version.h
But if I put these lines in a CMD script (eg: createVer.cmd ) and execute it from the command line, I get the following error:
C:\> createVer
C:\> set arg=4.5.2-RC8
argi was unexpected at this time.
C:\> for /f "delims=.- tokens=1" argi
C:\>
Any idea what I'm doing wrong?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The command processor does some bizarre read-ahead stuff which can lead to earlier definitions going crazy.
See help set for information on delayed environment variable substitution - basically, you surround the variable name with ! rather than % .
I'll admit that when I was trying to do something similar, I wrote a C++ program. It's a lot more controllable.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks, Mike! I was able to fix it by using the %% notation (reqd in scripts).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It's a known issue with the command interp. Need to use %%i instead of %i when including commands in a script.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi People !
I ´m programming an 32 bit application that has to read a series of nunbers from a formated TXT file.
I was thinking about using fscanf but I realized that I need to open the file with fopen , that is an absolete function ...
Well.. I´d like to know if is there another alternative for fscanf , or if I can use fscanf even opening the file with CreateFile. Is there a new function to read a formated file , that is compatible with Createfile ?
Thank you in advande
|
|
|
|
|
|
Sorry !!!
I mean obsolete ...
Humm . I have heard about some people that had problems using it in 32 bit applications ...
|
|
|
|
|
arturapps wrote:
I have heard about some people that had problems using it in 32 bit applications
Which means they were not using it correctly. Being obsolete means that it is not available to use, correct or otherwise.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
arturapps wrote:
I need to open the file with fopen , that is an absolete function ...
What's obsolete about it? Are you using Visual Studio v7.x?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
i don't think fscanf is obsolete...
anyway, if you prefer the "younger" std::cin, you can thus read series of numbers too.
You will have to open a stream associated to your target file, and then do as much as cin as you want...
watch for iostream s in the msdn for details.
TOXCCT >>> GEII power
|
|
|
|
|
If you like, you can use a method other than fopen to open the file, read a line of text, and use sscanf to parse it.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|