help with sizeof ()

So, our computer teacher taught us about this function recently and asked us to create an app to calculate the string size using the same for every other function such as int, float, double, I have no idea how to use except to use it with parantheses, this is what I coded :

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;
void main ()
{char welcome;
cout << "Enter your welcome message here :" << '\t';
cin >> welcome;
cout << "The size of char 'welcome' is :" << '\t';
cout << sizeof (char) << '\n';
cout << "The size of double 'welcome' is :" << '\t';
cout << sizeof (double) << '\n';
system ("pause")
}


I'm obviously not using it in its correct way, could someone guide me on this?
sizeof is calculated during compilation. This means that the result of sizeof(x) will never depend on the value of x, only on its type. I can't say what your teacher wanted. Maybe to get sizeof an array?

Also, "using the same <what?> for every other function such as int, float, double<these are types not functions>"
Last edited on
Topic archived. No new replies allowed.