#include <iostream>
#include <cstring>
using namespace std;
int var()
{
string temp[4];
cout << "name of street where you live: \n";
getline(cin, temp[0]);
cout << "your age \n";
getline(cin, temp[1]);
cout << "rate your c++ skills [1 - 10]? \n";
getline(cin, temp[2]);
cout << "how long are you programming ? \n";
getline(cin, temp[3]);
cout << sizeof(temp); // this print out 16
return 0;
}
int main()
{
int i=var();
cout << sizeof(i); // this print out 4 explain this bullshit
}
why size of 'i' is equal 4 bytes when the function var() is containing 16 bytes strings?
>>51858672
>why size of 'i' is equal 4 bytes when the function var() is containing 16 bytes strings?
i is a int (you just initialized it one line above), and ints are 32bit=4bytes in 32bit programs.
Just because you assign the return value of a function that uses a string to i doesn't mean that it is changing it's type (in a static typed programming language like this).
>>51858672
Are you retarded?
>return 0;
>all that stupidity
>all that broken Indian grammar
this must be a copypasta from stackoverflow, right?
POO IN LOO DETECTED
> return 0;
Sure, why the fuck not.
#include <iostream>
using namespace std;
int main(){
int testNum=4235;
cout<<sizeof(testNum);
system("PAUSE");
return 0;
}
this print out "4" WTF /G/!!!!!
>>51858672
Integer is byte size 4, sizeof(int) == 4
You want thisint var(string temp[4])
{
cout << "name of street where you live: \n";
getline(cin, temp[0]);
cout << "your age \n";
getline(cin, temp[1]);
cout << "rate your c++ skills [1 - 10]? \n";
getline(cin, temp[2]);
cout << "how long are you programming ? \n";
getline(cin, temp[3]);
cout << sizeof(temp); // this print out 16
return 0;
}
int main()
{
string temp[4];
int i = var(temp);
cout << temp[0];
}
>>51858672
You just asked the size of an into you fucking retard, which is 4bytea on your shit tier x86_32 (or God tier x32, but I doubt you could get that working) system.
What exactly does this shitty program need to do
>>51858672
>return 0;
>>51859847
Obviously it should return 0. Always.