[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
#include <iostream> #include <cstring> using namespace
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 13
Thread images: 2
File: 1046.jpg (52 KB, 471x694) Image search: [Google]
1046.jpg
52 KB, 471x694
#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 this

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()
{
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
>>
File: poe.png (19 KB, 267x302) Image search: [Google]
poe.png
19 KB, 267x302
>>51858672
>return 0;
>>
>>51859847
Obviously it should return 0. Always.
Thread replies: 13
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.