-
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
-
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).
-
-
It's another number base. We have decimal (base 10, should be denary but hey :p) which uses digits 0 to 9. Hexadecimal uses 0-9, A-F. Octal uses 0-7.
-
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 :)
-
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.
-
-