C Programming Tutorial – 46 – Problems with String Lengths

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts


Chewela Nthani says:

Thankyou so much for teaching us programming.
I will definately be watching these videos for a long time.
the plan is to first learn C, then C++, then C# then Java…
the rest is a bit fuzzy

skylar blusterx says:

faggots everywhere…

Chewela Nthani says:


Sara S says:

Thanks man! you are really THE Man! and btw, some of your jokes are funny 😉
Good job in sum!

Ariana says:

i really thought i was gonna go to jail

Simou Riche says:

why the use of pointer here ??

AJay Gupta says:

Respect bro / you’re amazing man. yiu made this at 4.34 AM wow no words for you !! may god give you healthy and rich life.

Saif Khan says:


D. Refaeli says:

4:37 am. Bucky – you’re a real hardworking man!

puru says:

Stay safe.

Use fgets.

Sam says:

Why do you need the pointer variable, when movie itself can be used as a pointer?

char movie[4];
fgets(movie, 4, stdin);

Animesh Kumar says:

whats difference between using %x and %p for pointers?

Peter C says:

Oh men.I just got out of jail.

Suleiman Al Riyami says:

you made this at 4 am ??????????? ur freakin hooked man !! major respect bruh…… i appreciate what u do ..

Muck2014 says:

Why less than 20 charactes?

Tomasz Kolodziejczyk says:

Why not to use: “scanf(“%19s”, pmovie);”. It works the same way as “fgets(pmovie, 20, stdin);”? There are many ways to achieve a goal. It is worth to know more than just one. Anyway, Bucky you are still awesome:) btw for more info about pointers go to mycodeschool. Apart from accent, he is as awesome as Bucky:)

Many Dog says:

papa bless

Certified M says:

Urgent message:Why does he use ‘puts’ instead of ‘gets’ like the usual way, in the last stage where he prompts the user to input a string?

Robert RR says:

Too vague

Unknown Account says:

fgets (pMovie,20+1,stdin); This is going to make it show the 20 bits instead of showiing the 19 bits

Suraj Jagtap says:

can you give me the tutorial of how to use open CV with c++

Vishal Kumar says:

bosdk 19 character hi print hue benchod!!!!!!!!!!!!!!!!

talal alsharaa says:

Why do we need to do this hard stuff
While we can do it simpler like this

Char movie [20];
Fgets (movie, 20, stdin);
Puts (movie);

And have the same result

irving c says:

You taught me C better than both my textbooks and professor.

Edward Keselman says:

It’s important to mention that fgets() also reads the new line character ‘n’, so if you want to have a string with 7 characters max, and you use fgets() and enter “Hello” then the length will be 6 and not 5 because it was read as “Hellon”. It’s important to remember to get rid of that ‘n’ sign.

Didi Sidi says:

Hi, God Bless you for your time spending
giving a free education ,that very expensive to pay for
I have a huge request if possible . The screen when you type is almost invisible even on a huge screen, if you can spend sometimes to change it.
I know it time consuming but without it the tutorial are not very effective unfortunately
and that can be just waste of your time
Thanks for getting time to read me
Bless you
Best wishes in your mission

Theanat Sreng says:

I have a question?

the “fgets”
fgets (movies, 20,stdin)

what is “20” use for?
and stdin??? (do you mean the input from keyboard?)

Michael Moore says:

I better follow the programming laws. I don’t want to go to jail.

Aquiles Baeza says:

Please zoom.

Delta // Top 10 Minecraft Songs says:

For the sakes of security in your programs, use fgets instead of gets or scanf. 

If you have a char array that has 100 elements and the user enters 101, it can crash or harm the program. When using fgets, you can make sure the user has a limited amount of space for a title.

kailash rajpurohit says:

Video being recorded at 4 AM . Respect man !! Respect.

mr fool says:

I disagree you can do something like this https://gist.github.com/mr-fool/f548041b9a8c1077beae At least this is what I do (VLA). Prompt user for array size then create array @ run time. DONE

Jesper says:

Why do you guys want to learn this? I find it fascinating that so many people think this is fun. Im not hating on you people, I’m just curious. Please reply with what your drive or motivation is! 

Danjoker says:

I went to jail for this

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!