Apr 18, 2016 at 8:33pm UTC
Learning C++ and windows programming. Received errors before debugging in the following example taken from "C++ Demystified":
// ConsoleProject2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "sizeof.h"
#include <iostream>
using namespace std;
int main(void)
{
cout << "Sizeof short is"
cout << "Sizeof int is"
cout << "Sizeof long is"
cout << "Sizeof float is"
cout << "Sizeof double is"
cout << "Sizeof long double is"
cout << "Sizeof char is"
cout << "Sizeof bool is"
return 0;
}
Apr 19, 2016 at 8:36am UTC
The code looks incomplete. The cout statements gives you an error because the lines does not end with a semicolon. You probably also want to add sizeof to print the actual sizes.
cout << "Sizeof short is " << sizeof (short ) << '\n' ;
Apr 19, 2016 at 11:32pm UTC
hey thanks alot it worked! this is my 2nd c++ tutorial. Cant wait to learn more.
Apr 21, 2016 at 2:29am UTC
I dont think you need the "sizeof.h" library for this im pretty sure either
"stdafx.h" or <iostream> contains the 'sizeof()' function
Apr 21, 2016 at 6:45am UTC
sizeof is an operator. It's build into the language so you don't need to include anything to use it.