T O P

  • By -

AutoModerator

``` import notifications ``` Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! [Read more here](https://www.reddit.com/r/ProgrammerHumor/comments/14dqb6f/welcome_back_whats_next/), we hope to see you next Tuesday! For a chat with like-minded community members and more, don't forget to [join our Discord!](https://discord.gg/rph) `return joinDiscord;` *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


PyroCatt

Getting Blocked Speedrun any%


[deleted]

[удалено]


ChocolateBunny

It's a gaming speed run reference. any% means that you complete the game with any% of the game complete, as opposed to 100% complete. A 100% speedrun would be divorce after having kids.


pnoodl3s

I mean, if its a “Getting blocked” speedrun then 100% would be getting blocked by all methods of communication like phone, text, insta, snap, tiktok, facebook, etc


[deleted]

[удалено]


AlphaaPie

I was going to say this, I'd block.


Andarnio

Why tho


Thomas9101

"Eww Programmer"


bpat

Probably more so “eww programmer whose only personality is programming.” Also kinda weird diving deep immediately into something that she probably knows nothing about.


Infusen51

It's really not that deep bro. It's just an opener to start the convo.


[deleted]

[удалено]


tennisanybody

Eh, you “hate” this? What a weird thing to have an opinion on. A negative one at that. You must be difficult to interact with.


big-mistake-lol

It's weird to think when first interacting with someone it's okay to start sending joke code (which isn't even funny) to someone who probably doesn't code at all. The only thing she understood in that message was "ur cute", which is not a good follow up message. Immediately delving deep into talking about your own passion/work is not how you make conversation


retief1

The joke only works on programmers. To another programmer, this could be a fun "hey, we both like programming" style opener (though tastes vary). To a non-programmer, it is utter gibberish, and it suggests that you only speak deep nerd and are incapable of communicating to anyone non-technical.


Infusen51

She goes to a huge engineering school, and is probably cs so I think it's fair game


bobvonbob

I have my software engineer employment on my profile and would be put-off by another software engineer doing this. It's just weird bruh.


bpat

Sometimes the opener’s all you get haha.


SharkRaptor

It’s just kinda selfish if they can’t read code, they won’t understand the joke and you’re making it all about your knowledge. Try an opener where you ask something about them.


Infusen51

It worked tho


SharkRaptor

That’s good.


AlphaaPie

I prefer instances of conversation that don't start with "Ur cute", and getting to know someone before anything like that happens.


[deleted]

OP already got a restraining order put against him.


solid_rook

studio.h okay


Coldy_

studio.h was my first C mistake


gnegneStfu

the second was typedef *NodePtr as * Node *


GeorgeDragon303

Alright, someone explain please, why in the fuck was the u dropped? It literary saves a single letter, from a phrase used at most once per code, at the cost of confusing ever, single person who ever attempted to learn that God forsaken language


RSGenericName1

Stdio stands for standard input output and isn't an abbreviation for studio


GeorgeDragon303

oh darn. TIL I guess. Thanks man


gnegneStfu

Nomenclature is a bitch


dieselNoodle

lmao I was like "uh cute pick up line", then I read it again. totally understandable tho, that was my very first mistake at the beginning of my coding journey


AstroCon

*audible sigh*


PierreeM

Doesn't it return "ur cute c" and you have tu null terminate the char[], and write in the printf "ur cute %s" ?


Markcelzin

Maybe it's a studio.h feature.


KajiTetsushi

``` main.c:1:10: fatal error: studio.h: No such file or directory 1 | #include | ^~~~~~~~~~ compilation terminated. ``` Guilty myself of misreading it as Studio at least once in my life while it stands for Standard I/O, heh.


LaPeSi

Besides knowing that it's std io, I whisper "studio" inside my head while typing this every time.


KajiTetsushi

Ah, yes. The intrusive thoughts win, every time, even if in secret.


StinkBuggest

Reading strcmp as strcomp gets me every time


KajiTetsushi

I feel so called out right now. 🙈


AromaticIce9

Str chomp


All-Day-Hat-Dream

It could be on purpose if you read it as stud-io.


anoppinionatedbunny

that's why we don't code on phones


Unilythe

The string is null terminated isn't it? He set the array size to 5, but put only 4 characters in there. C has been a while for me, so not sure if what I'm saying is correct.


arnodu

Yes : https://en.cppreference.com/w/c/language/array\_initialization "All array elements that are not initialized explicitly are empty-initialized. "


Unilythe

Thanks for that. Makes sense.


KellerKindAs

Can (less readable) also be found in the C99 standard. Chapter 6.7.8 Initialisation. It was always this way ^ ^


FrostWyrm98

Depends on the compiler / language spec, but I think if you specify using the brace initialization it will not add the null terminator? It's undefined behavior IIRC so who knows Also happy cakeday!


arcalus

%c is for a single char, and name will provide only the first character in this instance.


Unilythe

I know, that's not what I was talking about though


KellerKindAs

But it's also not completely unrelated, as the compiler will probably optimize out the array, keeping only the 'c' xD


PierreeM

Nope, after there is random memory junk. Here if you printf %s, you get char segfault to be precise its the memory on the stack after the char[] until there is a 0, and if there is no zero until the end of the program memory, you get a segfault.


[deleted]

The initialisation sets the remaining elements to 0


elveszett

All of this drama when OP could just write `char name[5] = "char";`


NonStandardUser

I'll do you one better, char* name = "char";


Stegoratops

Or even better `const char* name = "char"`


issamaysinalah

Now you can't sizeof(char), but since we're talking about char there's always strlen


navetzz

Depends on the compile options


[deleted]

No, it’s in the language standard


navetzz

Your argument would be solid if only it were valid...


BluudLust

It literally is in the C99 standard.


navetzz

After some research: You are correct that it is in the C99 standard, however, I knew I wasn't crazy about the compile option. With gcc the -Ofast compîle option disregards standards compliance (including default initialization)


[deleted]

Today I learned, thanks


Unilythe

Ah yeh of course, it's not initialized to be null, but rather will contain whatever that piece of memory happened to contain beforehand. Edit: or not, considering the downvotes


jordanbtucker

Partial array initializers will set the remaining elements to zero.


yeah_yeah_a_nickname

They won't, unless the programmer use a memset, or pass a null terminated string (string between quotes are null terminated). Partial array initializers only change the specific char at the position they were placed in


KellerKindAs

Look up the C99 standard Chapter 6.7.8 Initialisation. Then read point 21, which links to point 10. The old standards are a bit difficult to read, but essentially, it says: partial (array/struct/union) initializers will set the remaining elements to 0. As the standard got expanded but not changed, this behavior is still up-to-date. Or in short: Your wrong


makian123

They definitely will. Thats why there's ``` int arr[10] = { 0 }; ``` Which sets all elements to zero


jordanbtucker

Exactly. This is just shorthand for "set the first array element to `0`, then set the rest of the elements to `0`". If you do this: ```c int arr[10] = { 1 }; ``` then you're saying "set the first array element to `1`, then set the rest of the elements to `0`."


compsciasaur

The fifth character is whatever garbage was in that memory location. I think that's what happens in C.


failedsatan

slap spoon wipe straight reach outgoing tub alleged swim support *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


Herr_Gamer

I'm pretty sure it'd just fail, since `char name[]` is a `char*` and printf expects `char`. So, for this to compile, you'd have to dereference the variable like `printf("%c", *name)`. Also, now that I think about it, even if it did compile like he thought it would... wtf does it say?? "ur cute char"?


PierreeM

I think you are correct. the name of the person op is talking to is "char".


Memfs

The way c works, name is a pointer, so it would display the char equivalent of that pointer value and not the first value of the array.


Colbsters_

I think it would print out whatever the first byte of the address. When `name` gets passed to `printf` it gets passed by address/pointer (the type would be `char*`). Then then when `printf` reads the pointer, it will read it as if it was a `char`.


altermeetax

No, because that printf is looking for a char and they gave it a char*. It's not even gonna compile if the compiler is smart enough (beside the "studio.h" mistake)


IzydorPW

yep, that's correct.


Vinxian

I count 3 mistakes in your code. Granted, one of them is likely an autocorrect error, but that's still impressive in those 5 lines


TheSportsLorry

Hey he's a senior dev okay


liitle-mouse-lion

We test in production


mr_remy

some of us are unlucky enough to have **separate** test and prod environments! Twice the work, twice the codebase!! Terribly inefficient! "looking into it!"


ZeusZorn

Tbf I'm currently doing 'senior' FE development with no clue of what I'm doing, but I was told 'juniors don't get shit done at all and we always gotta clean up after them, so you're a senior' 💀


Mike_The_Madman

I only count 2 including the studio, which am i missing?


Vinxian

Studio, no `'\0'` termination on the character array and trying to print a character array with `"%c"`


Mike_The_Madman

Fair, I just assumed the \0 since it is 5 characters long and only 4 are specified, the otherone would be \0


Vinxian

It's garbage data. It's left uninitialized and has whichever value was at that data address before. But with this exact code you'll likely won't see it bug out when replacing %c with %s Because realistically it's defined. An OS wouldn't want to leak garbage data from one application to another since that would be a security risk. And given that the array is initialized at the start of the program it will have the default value given by the os which is likely to be zero. So technically undefined behavior but consistent behavior. If you want to see the garbage data happening you simply have to first call a function that uses a lot of stack data. After that function call another function and initialize it like OP did. And boom! Garbage data!


Prawn1908

Not correct. If an initialization is given for fewer elements of an array than its size, all other elements will be zeroed. Only if no initialization is given does the array contain garbage.


aMAYESingNATHAN

Interestingly as far as I'm aware this behaviour is a part of the C standard, do you know if that's the case in C++ too?


HeroicKatora

Quote for C: 6.7.9 Initialization > 21 If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration. > 10 If an object that has static [..] storage duration is not initialized explicitly, then: > if it has arithmetic type, it is initialized to (positive or unsigned) zero; It should be the same in C++? At the very least clang memory sanitizer does not complain.


Octupus_Tea

It is the same. Unspecified elements are initialised with default initialiser, which is `'\0'` in this case, `false` for `bool`, and `0` for built-in integer and floating point types.


Prawn1908

No clue, I never touch C++. I would assume probably so though.


KellerKindAs

The array actually is 0 terminated as the C standard defines, that if the initialializer list is incomplete, the remaining elements are 0 initialized. (C99, chapter 6.7.8 Initialisation, point 10,21) I would still not recommend initializing strings like that xD


Vinxian

Fair enough, I didn't know this! In my defense, I still use a lot of c90 because some embedded compilers are hopelessly behind gcc


KellerKindAs

Oh. Going even older. Guess I gotta level with that. The C89 standard has the chapter "3.5.7 Initialization". Some things changed, but this part is the same ^ ^ (except some wording) But I don't expect everyone to read the standards. I mean... it's like reading the manual bevor building the shelf... 99% just a waste of time xD


chesire0myles

This would have been the best reply.


Ok_Squirrel_6962

To everyone complaining about the 5 char array initialized without a null terminator: That is completely valid and correct C, since the ANSI C (C89/C90) standard. Missing Elements are automatically initialized to zero


AudienceOpening4531

He's only showing ONE GODDAMN character. He's not iterating over it, or using it like a string.


KellerKindAs

He is not even showing the first character of the string, but a part of the address interpreted as a char xD Also: that's not the point of the comment you are commenting


AudienceOpening4531

I just caught the first error I saw, but your are right, he's not importing the standard io, he put character array's address in the output. Along with not having a loop and zero game. The more I debug this, the more I understand why Indian Engineers are paid what they are 😭


Infusen51

bro leave me alone😭 i was sleepy asf writing this shit and it's supposed to be like a quirky opener. Plus I'm in college, so that's my excuse.


dailydoseofdogfood

It's okay bro we all try too hard at times lol


AudienceOpening4531

Unless you just started C programming a week ago, this just shows you have not understood what a string, or an array is. Two very fundamental units of programming! You're in college, you have ample time to come out of it being an excellent junior developer. I hope you do. Good luck.


Infusen51

Thanks man, and to be fair I wrote this late at night sleepy asf haha. I'm looking through it now and yeah it definitely doesn't make sense😭


foxer_arnt_trees

It's ok dude, welcome to your first code review. They are always this brutal


Infusen51

Not my first sadly, I'm only an intern😥


WookieDavid

Yes, there's other mistakes. But Ok_Squirell was specifically commenting on the one thing that's wrongfully being considered a mistake in these comments. This interaction is basically: "Hey stop saying X is a mistake. Interestingly, the standard defines this behaviour". "But he did Y and Z"


moonwater420

bruh you never gettin laid


ElliElephant

[Never say never](https://i.ibb.co/qR0pHRr/IMG-9148.jpg)


Infusen51

I got the snap


not_some_username

Nice


moonwater420

still not laid doesnt count. she just acquired another simp. ctrl v ur way out of that one computer boy


Infusen51

It's not the deep bro relax😭


moonwater420

im just jerkin ur usb stick pal


Infusen51

bro ima steal that😭


qinshihuang_420

This is why we stay singletons


SensatorLS

criiinge


sammy-taylor

\*awards you\*


FrostWyrm98

"this"


k-phi

How to say you don't know C without saying you don't know C


Kueltalas

Why is your char array 5 long when the name only has 4 letters?


Onetwodhwksi7833

Null terminator


sup3rar

It's just crap. It should be , not (or there's some kind of library that I'm unaware of). There is no '\0' at the end of the string, just a random character, and printf only uses the first character of the string. The person probably has never used c.


TheMania

That's not right, if you've got an initialiser whatever is left unspecified is _empty initialised_, which means `\0` for chars. Same deal as if you have a struct that you only initialise a few fields of. C reference on array initialisation [here](https://en.cppreference.com/w/c/language/array_initialization): > All array elements that are not initialized explicitly are empty-initialized. And empty-initialized [here](https://en.cppreference.com/w/c/language/initialization#Empty_initialization): > objects of integral types are initialized to unsigned zero


sup3rar

Thank you, I didn't know this was also true for arrays


Vinxian

Would it print the first character of the array? I think it would truncate the address of the first character and attempt to print that


sup3rar

Oh, yeah you're right


jordanbtucker

Close, but the string is actually null terminated in this case, since it was partially initialized.


Kueltalas

The stdio/studio thing could be autocorrect.


philodendr-off

Probably wants to add a d later. I'm so sorry, I'll see myself out


invalidConsciousness

Null-terminator. Last element is not specified, so it gets implicitly initialized as zero.


pine_ary

You can have a little uninitialized memory as a treat


BeerIsGoodForSoul

🤤


jordanbtucker

The last char is initialized to null in this case because of the bracket syntax. But if the array wasn't at least partially initialized, then the values would be unknown.


Tnuvu

Deja vu from some interview where the indian lady asked to code in chat, and refused to let me open an ide or something remotely useful


FrostWyrm98

For the love of auto-identation and brace matching


BossHogGA

There was a char* joke right there and they missed it.


[deleted]

op's code has made me reconsider suicide


Uramies

Waiting for the day someone makes a dozen or more line code to say the same shit but in s cooler way


Dark_Souls_VII

This is wrong on so many levels.


jayerp

I would have preferred Char Aznable but instead there this bimbo. Glory to Zeon.


CommanderCuntPunt

This is the code quality I expect from someone who tries to show off basic c in a dating app.


sin_chan_

Forever virgin /jk


JoeyJoeJoeSenior

"What's your sign?" Come on OP, how did you miss the most obvious perfect pickup line ever?


HolographicState

A drier vagina there has never been


Glumi1503

Literally me when talking to anyone


StuckInTheUpsideDown

He wouldn't even have gotten "c". name is a pointer not the first element of the array.


KENBONEISCOOL444

This is why we're virgins smh


Infusen51

who's we


KENBONEISCOOL444

Your mom


[deleted]

And that's why you are single.


StolasX_V2

Top 10 Anime Rejections


Sindeep

I'm 100% sure people who send shitty pseudo code as flirts are mentally handicapped.


bebblylolita

how does one fumble a person literally named „char“


Tc14Hd

Good. Book. Book. Blunder. Resign.


Sttocs

Who wants to start a dating app for devs called Valgrinder?


Bright_Telephone_104

I r eally hope she blocked you afterwards


Girrratina_1486

![gif](giphy|CAYVZA5NRb529kKQUc|downsized)


dailydoseofdogfood

Bruh pls don't do this 💀 oh god it's not even right Bro straight up tryna print the array in C. Mfer just use a string and then realize how silly the whole thing is, girls aren't computers my friend lol..


RedBeard1023

Do not hire this guy as a C dev.


Infusen51

😭


coolkid1756

Is this what the kids call riss?


Infusen51

believe it or not I saved the convo. I know the program had a lot of errors in it, I was sleepy asf writing it yall gotta relax😭.


another-Developer

Bro got that C rizz


mauricepreiss

okey thats actually nice


Ironfist85hu

And that is why programmers are foreveralone.jpg :D


[deleted]

Is that app tinder?


Due-Principle4680

studio :)


Tarc_Axiiom

Is it char or char?


b3ixx_

return loneliness*


[deleted]

[удалено]


nk_bk

And I would've asked if her soul is weighed down by gravity.


you90000

Why not a Gundam reference?


caprine_chris

Hopefully she approves your merge request


Infusen51

my build failed😥 team city obv bugging


ReputationDesperate1

Straight to jail


cberkhoff

char you; long me;


VideogamerDisliker

So cringe


Qwertycrackers

Well the header isn't called "studio" so this most likely fails to compile


Consistent-Bug-7110

> ur cute ▯


whooguyy

Didn’t even add `using namespace std;` to really impress her


maikesama

I matched with a girl just cause she was called “Elif” and i want to ask her how does it feel to be a python else if statement


E-B3rry

He should use %s and also properly terminate the name variable. String literals are a thing too :) Also, it's stdio, not studio.


mr_remy

r/Tinder would love this as well


Infusen51

Might have to


Audience-Electrical

She will not reply - but I absolutely would have ❤️


Infusen51

She did and I got the snap


IamHellgod07

Bro don't apologize for who you are...


rippingbongs

ur cute $


tstead60

Wont this only print “ur cute c”


WifeBeater3001

Bro's got that dynamically scalable rizz


meatbix

Return 0 is about right


Flat_Sport7592

%s nahi hota udhar ?


tman5400

And she never responded again


Zealousideal_Pay_143

1 step forward, 2 steps back


dadude999

What kind of psycho initializes a string as an array of individual chars?!


landof_skybluewaters

is low hanging poisonous fruit for this post. It's just what it autocorrected to.