Okay but it's easy to avoid buffer overflows with scanf if your format specifier gives a maximum length. Regardless, you should be taught to read raw data, SANITIZE YOUR INPUTS, and then parse with `sscanf` and use proper return values. scanf is incredibly fast and powerful when used properly, not like that clunky cin/cout business with c++
I tried to use scanf once and my compiler, Clang, warned me that it was deprecated and unsafe. If you're ever working with buffers in C, make sure you check to make sure the stuff that you put in the buffer isn't bigger than the buffer itself in order to avoid a buffer overflow exploit. Also be wary of buffer underflow exploits; this is a good case because C strings are null-terminated. If the stuff you're copying has length mismatches, don't even bother with it due to buffer over/underflow exploits.
@@wmpowell8 I don't know if I should do this, but I create a buffer of a fixed amount, and use fgets to read from "stdin". Then I just parse the buffer for the data I actually want.
The Actual reason for the unsafe code is that when he put "scanf("%s", input); There was a chance that when the user put more than 9 characters (including the null symbol) that scanf could override some data in next to that point in memory and write your input on some critical information. He also asked for an opinion
@@SomeRandomPiggo it only happens if input rewrites memory of other processes/programs. However, if it rewrites memory of only this process, you will deal with bugs and probably undefined behavior
and write your input on some critical information is like a horrible way of explaining what is going on, if you are a programmer, I mean it is killing me.
mayeb you can say more like disallowed memory location (e.g. due to lack of priviliges or just straight illegal) because it's not that easy to access other processes when they are all isolated by virtual memory technique. @@lex-ch3xv
If you're ever coding date systems or anything that uses a calendar in China, just remember: June 3rd is immediately followed by June 5th. There is nothing in between.
It means very bad wrongthink. You will be reeducated. A stack is what your cpu uses to store local variables (memory). In C the stack is only as big as you allocate (reserve...) - in this case 10 bytes. Scanf loads input data in this case onto the stack but there's no guarantee the input data is less than 10 bytes (10 characters), but C will happily write your extra data past the allocated stack memory thus causing all kinds of bad things to be possible ranging from your program crashing to you getting hacked. Like if you take your backpack and keep shoving shit in it it's going to rip and spill everything out. That's a stack overflow.
If that is a string so it must be has null at the last element automatically right? If that so , Will the bufferflow occurs when we type more than 9 characters or more than 10 characters?
@@suntzu1409 a relative of mine is an embedded software developer and likes to tinker with electronics so naturally he had to go to shenzhen. What he said, is mind blowing to me. You can obtain a GTX 1080 (example) for 1/4 the price, because they make them and those are for the chinese market. They had some off brand processors that were really interesting spec wise, although I forgot their name it was something in chinese. I'm 100% sure they have 4000 RTX series there already, it's just that the western media block everything good about china and just spread propaganda how people in china live in mudhuts etc... Even though an average Chinese citizen is actually richer than an average USA citizen, now ofcourse, china's standard is lower and so are the salaries but it doesn't make a difference when you don't import only export.
If I may ask, why are you using an old version of gcc? Here in my country when we use something outdated is because the University schedule hasn't been updated since it's creation but I thought that in China you would use the latest technology
@@juliangonzalez1207 I thought to myself that if I go to Chinese University that literraly launches robots to Mars and makes software for Olympic games I would be a great programmer and demanded specialist but the only thing I left with is studying C language using outdated software and tons of physics and chinese edition of electrical enginiring.
@@juliangonzalez1207 Chinese Universities has the same issue as yours. They just can't keep up with modern technologies that everyone use. And overall the technological progress in China is really overrated. Take a look at any chinese website. They really bring some 90-s vibes
After being a programmer for a few years, I got a new phobia: I'm afraid of pressing any buttons in GUI applications. When I see buttons, I make sure that any progress I made was saved at least 3 times, and when the button is pressed, I pray for the application not to fall, I pray for OS to overcome such a stressful process as handling function binded to that button and I feel totally happy when I see no BSODs on the screen after the button released. Why am I saying it in comments after this video? Cause if Chinese programs are really written this way, there is still a hope that this world's software can be usable
0:23 Does anyone know where those corny smileys came from that keep getting used ironically in memes? I do remember that they could be used in ICQ. Which makes them ancient by internet standards.
@@heroes-of-balkan characters are numbers (in C). 1 byte numbers. They represent the ASCII code of the character but nothing is stopping you from using them like a regular number (not recommended). You can even perform arithmetic on them - 'a' + 1 is 'b'.
He did not thank the goverment for the opportunity. That was a first mistake. He also did not provide a backdoor for the secret service. Oh wait, he did
Chinese programmers write comments in Chinese. Other than that… (You can use Chinese for variable and function names as well because they are unicode characters and does not include spaces)
ah yes scanf controversial but the most dangerous thing is strings themselves, not scanf *meanwhile me reading thousands of lines from a file and parsing it's contents*
If that is a string so it must be has null at the last element automatically right? If that so , Will the bufferflow occurs when we type more than 9 characters or more than 10 characters?
@dingel_91716 10. But if u write 10 chars, ur string wont be terminated and if u try to print it, ull get some trash characters from the next bytes in memory, till it hits a 0
C is very cool. For me it only has upsides. Love lower level languages. But it goes down way deeper to. Like Assembly but here it becomes very hardware specific. But what is even more important is having the right tool for the right job. That can mean different things. example if you know many languages you can choose an language for the right task. But if you are a master in one language you can do most tasks with one language alone. remember if all you got is a hammer, all problems start to look like nails.
At least they are one of a few governments that is trying to ditch Windows in favor of Linux for their state apparatus, which I think is a great thing to do.
The US just uses another OS specifically designed for government use. Its not linux but its based off UNIX like linux was. They use windows sometimes but mostly uses that specific OS. Especially on the F35
@@siyustuff213unsafe scanf Using %s reads a string of any size, thus the user has the hability to write like 60 chars and write beyond the allocated input array. It should be %9s to limit it to 9 chars read, cuz 10th slot is for \0
As a native Mandarin speaker from Taiwan, the fake subtitles at the end makes me understand how do the Germans feel like when they watch Downfall parodies lol
The incident of Tiananmen Square protests and massacre happened In june 4th, 1989. this incident was primarily caused by the death of General Secretary Hu Yaobang, economic reforms, overinflation and corruption, to which the results led to Many students during their demonstrations being killed by Chinese troops, Pro-Democracy movements and enforcement of martial law.
The code reads input from the user using the scanf() function and stores it in the input array of characters. However, there are several potential problems with this code that could lead to errors or unexpected behavior: The size of the input array is limited to 10 characters, but there is no check to ensure that the user's input does not exceed this limit. This can result in a buffer overflow, which can lead to a program crash or other security issues. The %s format specifier used with scanf() can read a string of characters terminated by whitespace or a newline character. If the user inputs a string that is longer than the size of the input array, or contains whitespace, the behavior of the program is undefined. The scanf() function returns the number of input items successfully matched and assigned, but the code does not check this return value. If the user enters input that cannot be assigned to the input array (e.g., a non-string value or a string longer than the array), the program will not know that an error has occurred. To address these issues, you could modify the code to use a safer input function such as fgets() instead of scanf(), and add checks to ensure that the user's input does not exceed the size of the array. For example #include #include int main(void) { char input[10]; printf("Enter input (up to 9 characters): "); fgets(input, sizeof(input), stdin);
// Remove trailing newline character from input size_t len = strlen(input); if (len > 0 && input[len-1] == ' ') { input[len-1] = '\0'; }
return 0; } In this modified code, fgets() is used to read input from the user, and the sizeof() operator is used to ensure that the input does not exceed the size of the input array. The code also removes any trailing newline character from the input using strlen() and input[len-1] = '\0'. Additionally, you could check the return value of fgets() to ensure that input was successfully read, and handle any errors accordingly. source: ChatGPT
I was thinking since I know a little C and programming I will live as a hero with high social credit in China but then I remember all the unsafe code I've written 😂😂
China: your code is unsafe, -100 social credit, code better next time US: thanks for your input, we really appreciate your contribution, unfortunately we cannot accept your PR , if there is something you wish to talk about, please contact the employee satisfaction insurance team
for most people who don't know C, including me, scanf() is like the main thing for every input. For example: scanf("%i", &inputvariable) printf("%i") Output: (the thing you entered in the input) Atleast I'm pretty sure it's like that...
wait until you learn about the engineer leaking the police database credentials, leading to every person in shanghai getting their full name, address and phone numbers leaked.
You are vulnerable to a stack overflow. You limit the string to 10 characters in the stack but the string you get is not limited to 10 characters. So it can overflow and overwrite memory in certain places you dont want it to. Causing problems.
We can't make choice on our device with the latest version of softwares, this is what big tech have done and I think big tech really love "China"(government)
The joke is that the program is asking for input, but in China public's opinion is not allowed.
This also makes sense, but scanf function is generally unsafe as it may cause stack buffer overflow vulnerability
I wrote the exact same comment but somehow yours escaped me. Honestly this is funnier to me 🤣
Oh ok, I only rly code in python and java and a bit of c++
thats alao untrue
that's not the joke but that's a funny take on it
Started my CS major last year, teacher wouldn't shut up about scanf the entire semester, so this is what his classes felt like.
Okay but it's easy to avoid buffer overflows with scanf if your format specifier gives a maximum length. Regardless, you should be taught to read raw data, SANITIZE YOUR INPUTS, and then parse with `sscanf` and use proper return values. scanf is incredibly fast and powerful when used properly, not like that clunky cin/cout business with c++
i love this comment
why use scanf when you have std::cin
Because this is C, not C++
@@stevefan8283 Because coding in c++ is a sin
I'll save this video. Go learn C and comeback to get it.
Edit : i end up learning python
Googling "scanf unsafe" will probably help you a lot.
I tried to use scanf once and my compiler, Clang, warned me that it was deprecated and unsafe.
If you're ever working with buffers in C, make sure you check to make sure the stuff that you put in the buffer isn't bigger than the buffer itself in order to avoid a buffer overflow exploit.
Also be wary of buffer underflow exploits; this is a good case because C strings are null-terminated. If the stuff you're copying has length mismatches, don't even bother with it due to buffer over/underflow exploits.
@@wmpowell8 I don't know if I should do this, but I create a buffer of a fixed amount, and use fgets to read from "stdin". Then I just parse the buffer for the data I actually want.
@@BSPNode I do the same thing! That's definitely safe
@@SENTRY456123 Scanf is unsecure with strings because it has no fixed length
I thought the negative social credits were because you asked for user's opinions rather than hard-coding the government's.
Though so too and honestly this version is funnier
@@Manu-se5tx Even online I still have no idea what "this" refers to...
@@hashtags_YT OP's version
My stupid ass technically thought that was the reason.
government is the user as well
It is rumored that when you divide 6 by 4 with '/' operator you will be invited to the local police station for tea
Jokes aside, why?
Date of the Tianmen square massacre
@@yeaboi3593 -999,999,999,999 SOCIAL CREDIT!!!
@@yeaboi3593 nothing happened in Tiananmen Square
@@davidugono3727 nooooooo
The Actual reason for the unsafe code is that when he put "scanf("%s", input); There was a chance that when the user put more than 9 characters (including the null symbol) that scanf could override some data in next to that point in memory and write your input on some critical information.
He also asked for an opinion
I think the OS stops that from happening and kills it with a segmentation fault
@@SomeRandomPiggo it only happens if input rewrites memory of other processes/programs. However, if it rewrites memory of only this process, you will deal with bugs and probably undefined behavior
Fuck that sounds terrible
and write your input on some critical information is like a horrible way of explaining what is going on, if you are a programmer, I mean it is killing me.
mayeb you can say more like disallowed memory location (e.g. due to lack of priviliges or just straight illegal) because it's not that easy to access other processes when they are all isolated by virtual memory technique. @@lex-ch3xv
We need a new ".ccp" file format
Ah yes, the CC+ language
+25 social credit
@@thatchapthere *CCP+ language
-999999 social credit for you
Let me guess:
Only CCP can write programs in this language
@@suntzu1409 its CPC not CCP, -1/0 social credit for xenophobic act
Just replace 'input' with '(char *)argv'. If there's not enough memory then at least it's not your fault.
Also, if you want to automate the program, using arguments instead of using scanf() is much more suitable.
You'd destroy the entire command line parameter array
@@shu3684 which stands for scanf secured amirite
@@shu3684 Nah, real programmers use gets.
/s
This is so 5Head I can't believe it.
In China they don’t learn C. They learn A+
Are you sure?😅we don't learn c?😅
stereotype😅😅
No they learn A++
@@clidlove its a joke dumbass
Nah
We learn 共产党+
If you're ever coding date systems or anything that uses a calendar in China, just remember: June 3rd is immediately followed by June 5th. There is nothing in between.
Nothing happened on June 4th, 1989. I can confirm as I wasn’t there since nothing happened.
Yeah we ain't seen nothing
Huh no, im chinese
@@lostzhengli1060 金水桥
June 3 and June 5 are both 36 hours long, there is no June 4th
the code says: "Taiwan is a country"
social_credit -= 999999;
Social credit deducted
Your execution will be in 2 hours
"WARNING: Your execution is scheduled for tomorrow at 8 am."
Execution date: now
@@onichan6897 execute(user);
For those do didn't understand, this code is vulnerable to stack/buffer overflow
My brother in christ I don't know what that means
In non coding language?
It means very bad wrongthink. You will be reeducated. A stack is what your cpu uses to store local variables (memory). In C the stack is only as big as you allocate (reserve...) - in this case 10 bytes. Scanf loads input data in this case onto the stack but there's no guarantee the input data is less than 10 bytes (10 characters), but C will happily write your extra data past the allocated stack memory thus causing all kinds of bad things to be possible ranging from your program crashing to you getting hacked.
Like if you take your backpack and keep shoving shit in it it's going to rip and spill everything out. That's a stack overflow.
If that is a string so it must be has null at the last element automatically right? If that so , Will the bufferflow occurs when we type more than 9 characters or more than 10 characters?
Yh I remember my first c project I had to clear the buffer every couple lines cuz I was too lazy to rewrite any code.
This is why Chinese have the best quality Linux wifi drivers.
Including 802.11n
And highest quality of basically every kind of electronics you can imagine
@@suntzu1409 dude anyone can make better quality electronics but to claim a price is a game of import and export data
@@suntzu1409 a relative of mine is an embedded software developer and likes to tinker with electronics so naturally he had to go to shenzhen. What he said, is mind blowing to me. You can obtain a GTX 1080 (example) for 1/4 the price, because they make them and those are for the chinese market. They had some off brand processors that were really interesting spec wise, although I forgot their name it was something in chinese. I'm 100% sure they have 4000 RTX series there already, it's just that the western media block everything good about china and just spread propaganda how people in china live in mudhuts etc... Even though an average Chinese citizen is actually richer than an average USA citizen, now ofcourse, china's standard is lower and so are the salaries but it doesn't make a difference when you don't import only export.
@@razpaqhvh7501 THANK YOU FOR FINALLY SAYING THE TRUTH
printf(“Zao shang hao! Wo you yi ge bing chilling”);
Redundant code in the description. -100 social credit.
Just execute the code, not me.
@@SENTRY456123
Just execute the code?
More -♾️♾️♾️♾️ social credit
Your execution date is tommorow
@@SENTRY456123 captain philips has entered the chat: i know (evangelion ed lyrics)
As a programming student studying in China I can relate. Except we are coding in Dev-C++ in gcc 4.8
If I may ask, why are you using an old version of gcc? Here in my country when we use something outdated is because the University schedule hasn't been updated since it's creation but I thought that in China you would use the latest technology
@@juliangonzalez1207 I thought to myself that if I go to Chinese University that literraly launches robots to Mars and makes software for Olympic games I would be a great programmer and demanded specialist but the only thing I left with is studying C language using outdated software and tons of physics and chinese edition of electrical enginiring.
@@juliangonzalez1207 Chinese Universities has the same issue as yours. They just can't keep up with modern technologies that everyone use. And overall the technological progress in China is really overrated. Take a look at any chinese website. They really bring some 90-s vibes
@@jopaslona1 That sucks, good luck mate
@@jopaslona1 either your faculty is shit or the uni you go to is shit, may I ask which uni you went to?
After being a programmer for a few years, I got a new phobia: I'm afraid of pressing any buttons in GUI applications. When I see buttons, I make sure that any progress I made was saved at least 3 times, and when the button is pressed, I pray for the application not to fall, I pray for OS to overcome such a stressful process as handling function binded to that button and I feel totally happy when I see no BSODs on the screen after the button released.
Why am I saying it in comments after this video? Cause if Chinese programs are really written this way, there is still a hope that this world's software can be usable
Not enough comments, *-5,000 social credits*
Non conventional main signature, *-1,000 social credits*
0:23 Does anyone know where those corny smileys came from that keep getting used ironically in memes?
I do remember that they could be used in ICQ. Which makes them ancient by internet standards.
They look like those emoticon packs for MSN messenger that installed a virus in you PC
I don't know but I'd like to, as well
Back after 10 months, thank you for getting me to learn C, it's my favourite language now :)
As a chinese which learning C++ I can confirm that if I don't return 0; , I'll get arrest
hint: scanf("%9s", string); // leave room for the null terminator.
should use char input[10] = {0}
Bruh moment
Wouldn't that cause an error? How to put an integer to a character array?
@@heroes-of-balkan It's just initializing the array to the value of zero, which in ASCII is a null value.
@@heroes-of-balkan characters are numbers (in C). 1 byte numbers. They represent the ASCII code of the character but nothing is stopping you from using them like a regular number (not recommended). You can even perform arithmetic on them - 'a' + 1 is 'b'.
@@pyrodynamic4144 that is true, but 4 bytes in 1 element that can store 1 byte made me scratch my head
life is too short to be coding in china
*life is too short __because__ coding in china
you mean life gets short if you code in china
Life is too short because of living in china
using VS Code, social credit -1000000
Either church of emacs or cult of vim.
i use evil-mode its the best of both. But everyone has their pref.
Me using vs code cuz idgaf and just want a text editor with embedded terminal so I don't need 2 programs opened at once
I like how the video turned from a meme for entertainment to an educational content..
He did not thank the goverment for the opportunity. That was a first mistake. He also did not provide a backdoor for the secret service. Oh wait, he did
epitome of 21st century comedy
Fun fact: the “return 0” actually isn’t useless, it sets your social credit to 0
i use this as music for studying
Very true
Had my cousin work there and now he's gone.
im from china and the government authorities once showed up in my house because I tried to run a dangerous hello world program
1. 事实胜于雄辩。 (Shìshí shèng yú xióngbiàn)
- Facts beat eloquence.
From Lu Xun's "Hot Wind" (鲁迅《热风题记》), it's like, "Actions speak louder than words."
2. 一言既出,驷马难追。(Yìyán jì chū, sìmǎ nán zhuī / 'a word already produced, team-of-4-horses difficult chase')
haha
Chinese programmers write comments in Chinese. Other than that…
(You can use Chinese for variable and function names as well because they are unicode characters and does not include spaces)
why has this video been recommended to me so many times this week wtf...
The scream at the end: 🤣💀
I got a weird ad in Chinese before playing the video
Memory leak: -1000000 social credit
ah yes
scanf
controversial
but the most dangerous thing is strings themselves, not scanf
*meanwhile me reading thousands of lines from a file and parsing it's contents*
If that is a string so it must be has null at the last element automatically right? If that so , Will the bufferflow occurs when we type more than 9 characters or more than 10 characters?
@dingel_91716 10. But if u write 10 chars, ur string wont be terminated and if u try to print it, ull get some trash characters from the next bytes in memory, till it hits a 0
I really thought he was gonna create *public* variables in class
this is definitely the entire matrix code of what happened in tiananmen Square. apsolutely nothing.
Is there no "#define _CRT_SECURE_NO_WARNINGS" in China? LOL
😇👍
🇨🇳+ 15 social credits 📈
In China JavaScript is called TaiwanScript
It makes no sense but ok
Chef's kiss, Willy scream.
You've seen China's security, clearly no one would get executed for that
As someone who has never been to China, I can confirm this to be accurate
Oh well, I guess I have to use my power.
**insecure*
I subscribed you only because of your description. Good Job lol
//DEBUG BE LIKE:
class Person{
private: ...
^
Error: cannot use private property, -1000 Social Credit!
wait a second,properties are private by default in cpp. -1gazilllion social credits.
@@dragonlordsaviour7005 This is why the revolution had to take place, the world is capitalist by definition!!!!i!
how did i know it was going to be this song before i clicked on the video
¯\_(ツ)_/¯
C, C++, C#. The language of the damned.
C is very cool. For me it only has upsides. Love lower level languages. But it goes down way deeper to. Like Assembly but here it becomes very hardware specific.
But what is even more important is having the right tool for the right job.
That can mean different things.
example if you know many languages you can choose an language for the right task.
But if you are a master in one language you can do most tasks with one language alone.
remember if all you got is a hammer, all problems start to look like nails.
this makes me laugh even when i only know python lol
New favorite channel
I’ll start learning C just so I can understand this meme
"Yeah you gotta compile it to javasc[censored]t it can't run typesc[censored]t natively"
At least they are one of a few governments that is trying to ditch Windows in favor of Linux for their state apparatus, which I think is a great thing to do.
Well, North Korea did it first.
@@dumbstuff2809 they violated gnu GPL, so fuck them.
The US just uses another OS specifically designed for government use. Its not linux but its based off UNIX like linux was.
They use windows sometimes but mostly uses that specific OS.
Especially on the F35
@@honkhonk8009 most backends everywhere run on Linux. Even Microsoft themselves use Linux backends. Clouds,servers whatever.. all Linux
@@Nick-vd7cg torvalds moment
Me who was about to release an entire stacked app in china:
0:29 I hear "in Hong Kong" in Chinese XD
no joke, I literally started learning C to understand this meme 🤣
You know there are too many programmers in the world when there are designated RUclips channels shitting out "relatable" programming memes.
relatable for me
Most of the people who like "programmer humor" aren't even that competent
@@SomeRandomPiggo I see what you did there ;-)
Lol the description is just like me 😂🔥
aight time to go learn C so I can come back and understand this meme
update: i learned c and am chinese but still do not understand this meme. send help.
Buffer overflow
@@siyustuff213unsafe scanf
Using %s reads a string of any size, thus the user has the hability to write like 60 chars and write beyond the allocated input array. It should be %9s to limit it to 9 chars read, cuz 10th slot is for \0
Anyone else getting a Chinese ad on this video?
This joke is brilliant
Scanf is bad at getting string inputs
And also getting a opinion from a public(getting input from user) is not allowed in china
I thought it would be about him using char instead of wchar_t. That's very illegal for chinese input
As a native Mandarin speaker from Taiwan, the fake subtitles at the end makes me understand how do the Germans feel like when they watch Downfall parodies lol
When so I'm guessing next up is China++?
The incident of Tiananmen Square protests and massacre happened In june 4th, 1989. this incident was primarily caused by the death of General Secretary Hu Yaobang, economic reforms, overinflation and corruption, to which the results led to Many students during their demonstrations being killed by Chinese troops, Pro-Democracy movements and enforcement of martial law.
-999999 social credits 💀💀💀
Coding for Genshin Impact be like:
The joke is that great tech companies use chinese code
They actually write directly in binary
This had so many layers lmfao
The code reads input from the user using the scanf() function and stores it in the input array of characters. However, there are several potential problems with this code that could lead to errors or unexpected behavior:
The size of the input array is limited to 10 characters, but there is no check to ensure that the user's input does not exceed this limit. This can result in a buffer overflow, which can lead to a program crash or other security issues.
The %s format specifier used with scanf() can read a string of characters terminated by whitespace or a newline character. If the user inputs a string that is longer than the size of the input array, or contains whitespace, the behavior of the program is undefined.
The scanf() function returns the number of input items successfully matched and assigned, but the code does not check this return value. If the user enters input that cannot be assigned to the input array (e.g., a non-string value or a string longer than the array), the program will not know that an error has occurred.
To address these issues, you could modify the code to use a safer input function such as fgets() instead of scanf(), and add checks to ensure that the user's input does not exceed the size of the array.
For example
#include
#include
int main(void) {
char input[10];
printf("Enter input (up to 9 characters): ");
fgets(input, sizeof(input), stdin);
// Remove trailing newline character from input
size_t len = strlen(input);
if (len > 0 && input[len-1] == '
') {
input[len-1] = '\0';
}
return 0;
}
In this modified code, fgets() is used to read input from the user, and the sizeof() operator is used to ensure that the input does not exceed the size of the input array. The code also removes any trailing newline character from the input using strlen() and input[len-1] = '\0'. Additionally, you could check the return value of fgets() to ensure that input was successfully read, and handle any errors accordingly.
source: ChatGPT
I thought it was legitimate programming comment
scanf("%9s", input)
Then make a function for buffer clearing, most known one is:
Int c;
while ((c = getchar()) != 10 && c != -1);
(I forgot it if is an AND or an OR)
after coming back from learning C, I get it
Buffer overflow incoming
dang, i didn't knew that scanf was that lethal
print("Tiananmen square massacre 1989")
Wow we have very similar profile!
You are supposed to code in E (易) not C.
调试输出("Hello, world!")
Bruh why am I getting coding memes on my Recommended I don't even😭😭😭
scanf("%9s", input)
I was thinking since I know a little C and programming I will live as a hero with high social credit in China but then I remember all the unsafe code I've written 😂😂
He forgot to give the "&" symbol before "input" in the scanf statement.
China: your code is unsafe, -100 social credit, code better next time
US: thanks for your input, we really appreciate your contribution, unfortunately we cannot accept your PR , if there is something you wish to talk about, please contact the employee satisfaction insurance team
We like to keep all our code very secure. Not even our video games can be hacked and we like it that way.
for most people who don't know C, including me, scanf() is like the main thing for every input.
For example:
scanf("%i", &inputvariable)
printf("%i")
Output:
(the thing you entered in the input)
Atleast I'm pretty sure it's like that...
No , it's not
Basically yes but its more complicated than that
it's just like cin in C++?
Than enter a really long input, and you write something In storage, that is probably used for something else
missed the opportunity to make the vscode logo into a wechat or something
wecode lmao
no wonder Go is so popular there lmao
This needs more likes
Why RUclips recommend me a add from Albion online, but Chinese
You can limit scanf using some notation in the formating. My professor used that in vietnam.
your professor is a war veteran and computer scientist?? based
And we still lost the war?
Just add a number lol
%9s
@@DatBoi_TheGudBIASthat's one way to do it. using [^
] takes until the line break.
@@edunery ye, I use this tactic too when I want to read not only a word, but a whole string like phrase
wait until you learn about the engineer leaking the police database credentials, leading to every person in shanghai getting their full name, address and phone numbers leaked.
"VSCode LMAO"
My c++ professor is from China. I'm going to show her this video
How did it go?
💀
Our dear Professor Weiß be like
To everyone that doesn't understand... i don't get it either. But the siren was funny
i deadass though using scanf made codes unsecure and i started worrying so much😭😭
I'm learning C and I read string with scanf, why not recommended to use it? What is recommended to read strings in C?
You are vulnerable to a stack overflow. You limit the string to 10 characters in the stack but the string you get is not limited to 10 characters. So it can overflow and overwrite memory in certain places you dont want it to. Causing problems.
@@Lukyen thanks
use fgets instead
Either use "scanf("%9s", input)" to limit the number of characters read to 9 and have the zero terminator to get 10 or better C++ and std::string.
Your output would be like this "HelloWorld�[�G�"
We can't make choice on our device with the latest version of softwares, this is what big tech have done and I think big tech really love "China"(government)
You're using vs code a western software you already messed up
fake, they are writing code 10x faster