|
-
Nov 3rd, 2002, 10:43 AM
#1
Thread Starter
<?="Moderator"?>
structs
Code:
#include <iostream.h>
struct database
{
int USER_ID;
};
int main()
{
database users;
users.USER_ID=110;
cout<<users.USER_ID;
return 0;
}
heres my code, now this out puts 110, but when ui change users.USER_ID to 0110 it outputs 72????
im news to c++ so forgive me for the stupid question
Thanks
-
Nov 3rd, 2002, 10:52 AM
#2
Monday Morning Lunatic
Re: structs
Firstly, <iostream>, not <iostream.h>
As far as your numbers go, you've hit another intricacy inherited from C. When you give a number that begins with 0, it interprets it as Octal. I.e., 110 will be 110, but 0110 will be 110 octal, which is 72 decimal (check it on a calculator to see).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2002, 10:53 AM
#3
Thread Starter
<?="Moderator"?>
-
Nov 3rd, 2002, 10:59 AM
#4
Monday Morning Lunatic
It's another number base. We have decimal (base 10, should be denary but hey ) which uses digits 0 to 9. Hexadecimal uses 0-9, A-F. Octal uses 0-7.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2002, 11:02 AM
#5
Thread Starter
<?="Moderator"?>
gotya, o btw
when i use
#include <iostream>
i get the error
c:\C++\structures\source1.cpp(12): error C2065: 'cout' : undeclared identifier
but i only get a warning when i use
#include <iostream.h>
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\useoldio.h(29): warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated
? any ideas about thats
Thanks for the Help
-
Nov 3rd, 2002, 11:04 AM
#6
Monday Morning Lunatic
Heh, the warning about the other one tells you enough: the old ones are deprecated.
To use the new ones, they're all in the std namespace. So for simplicity, add a "using namespace std;" into the top of your source file, but after the includes.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2002, 11:05 AM
#7
Thread Starter
<?="Moderator"?>
cheers
-
Nov 3rd, 2002, 11:08 AM
#8
Monday Morning Lunatic
Nps
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|