C Video Tutorial 3

Get the Code Here : http://goo.gl/x3oiwE

In this tutorial I cover : exit(), switch, Arrays, Array Indexes, Problems with scanf(), Memory Overflow, strcpy(), fgets(), Array Interation, strcmp(), strcat(), strlen(), strlcpy(), Global Variables, Local Variables, Functions, and more…

The code above is heavily commented and will help you learn. Feel free to leave any questions you have.

Comments

Derek Banas says:

Thank you :)

MaydayTheVeil says:

The last globalVar was left unexplained? Is the 100 from the function changeVariables(); ?

oddball0045 says:

Undefined reference to strlcpy, may want to use strncpy instead.

Hize Hizake says:

Amazing Derek! Thanks!

Houwen Lie says:

So i was trying to make a program to simplify a statistical problems. The goal was to count frequencies for every single data collected. More or less :

#define FREQUENCY_SIZE 11
#define RESPONSE_SIZE 40

#include
int main(void) {
int frequency[FREQUENCY_SIZE] = {0};
int response[RESPONSE_SIZE] = {1,3,5,6,5,2,7,8,8,7,6,5,4……} >> here I enter all the data collected (just say, they’re students’ ratings of cafetaria’s foods)

BUT, when I enter those data, one of the element has a red underline which leads to an error : Too Many Initializers Values.

What caused it and how do i solve it? Thanks

Katido 622 says:

I have a question: I used fgets() in CodeBlocks, and it says
c:mingwincludestdio.h|673|note: expected ‘char *’ but argument is of type ‘int *’|
Which I think means it expects a Character, but is gotten a integer. Here is my Code:

#include
#include

int main(){
int a = 1;
int b = 12;
int c;
printf(“Enter another number.”);
fgets(c, 5, stdin);
printf(“Your Number is %d!”, c);
}

WAR NATION says:

why doest an array with ints need a stop sign at the end?

Zuokang Qu says:

15:35    = hello pie

Raul Saez Tapia says:

Johan Burger commented about problem of strlcpy on Linux with GNU C. You can use strcpy, at least for follow forward. You can’t do the limited copy of char array through function strlcpy but you can believe to Derek.

=)

Ali Amid says:

Derek, I have a suggestion. Your videos are really interesting and I learn much from them. But I think you can make them even better. At the end of every video, you should assign us with diffrent exersices where we can try out what we learned. I think that will help us to understand much better. Anyways, thanks for the awesome videos!

Shadi Namrouti says:

you’ve put the if statement outside the do while, it should not execute unless you put it inside the do while.

Mukul Sharma says:

i have a char ch and i want to get input from fgets how can i do it??

sportsquid says:

char yourCity[] = “Enghland”

Abdulnaser Sheikh says:

What if I want to make a keyword like global. This is like global keyword from python

Ani V says:

satisfied with these !! Really great :)

Rubik's Cubed says:

If I have printed newlines to the console as part of other strings for spacing purposes, is there then a way to ignore them with fgets()? My code keeps reading newlines somewhere as the end of my input, so the way I am doing it now is just with a character array of size 100 just accepting all of the newlines right before my real fgets() and this method just seems really stupid and by no means correct and I was wondering if there is hopefully a better way

Cal97g says:

How come the strcat function takes a byte array and not a pointer to the array? It takes the values not the reference but updates the value stored in the ref?

Sam Honarvar says:

Have no idea what you’re saying at 20:52. You can always define the method signature up before main and then define the body after your main. NO idea what it has to do with returning int or void. Can you clarify? Thanks!

Heath Bell says:

Does C hide more errors from programmer than C++ does?
It may be because I use DevC++ but whenever I type scanf(” %d”, &something), I usually forget the pointer “&” and my program still runs but then “stops working” after I type something in.

Zach Ward says:

Great videos. Clear and to the point.

TheRainbowLab says:

Derek Banas, you are my God… How are you so good!? You make programming feel like 3rd grade English

Derek Banas says:

You’re very welcome :) I’ll hold a vote soon on the next tutorial

Jan Bajc says:

Am switching from C++ to C. Great way to translate and refresh knowledge. Love your work!

uponlevels says:

These videos help a ton!

goalexboxer says:

nice work

Sung Lee says:

My first comment in youtube goes to you~ thanks for creating this series. helped me on shift to IT course

NorthernBolt says:

This is a great tutorial, by far better than any other C tutorial I have seen before. I just wish that there were assignments to go along with each video so that I had something to practice the new concepts with.

Zuokang Qu says:

at 5:59, why did u put a comma after the 5?

Naji Ould Es. Ahmed says:

Thank you, Derek, very muCh indeed!

Derek Banas says:

You’re very kind :) Thank you

sas10288 says:

Hi Derek,
What is the difference between char *string and char string[]? From my understanding, both of these are equally good ways to initialize a string.

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


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

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours