Video on Handling String Input With Spaces: kzbin.info/www/bejne/nGmYaWyPbrF7fsk
@alexcabrmz Жыл бұрын
Just an FYI, the link to this video in the description is broken.
@emmanuelenemali823811 ай бұрын
My God this was so exceptional and clear. Easy to understand as well. Thank you Sir
@abolipa01 Жыл бұрын
U r one of the best teachers
@gorkhalipahadi62212 жыл бұрын
Great i needed this 4 th day of csit So exicted
@PortfolioCourses2 жыл бұрын
Awesome! :-D
@NikitaSafronov-y6i2 жыл бұрын
Great video!! Cannot find next video "How to store string with spaces"
@PortfolioCourses2 жыл бұрын
It's this one here: kzbin.info/www/bejne/nGmYaWyPbrF7fsk. I think I will pin this comment and try to add the video as a link to this video, so thanks for letting me know it was tricky for you to find. :-)
@RochdiAarab4 ай бұрын
Thank you so much my teacher ❤
@BobChess Жыл бұрын
I have a question. How do you prevent the user from input the wrong type data. Like I use scanf("%d") but the user type the string and it's ruined my program.
@wiksilz13877 ай бұрын
Check the return value of the scanf if it equals -1 then something just went wrong like entering the a character when you do %d Hope this helps!
@GustavoNino-c1b4 ай бұрын
You can use an if else statement
@rezuwankabir33722 жыл бұрын
I had a question about integer and char int k = 0; printf ("Enter a number: "); scanf ("%d", &k); printf("k: %d ", k); char b = 'a'; printf ("Enter a char: "); scanf ("%c", &b); printf("b: %c ", b); When I do this It does not let me input the value of char in the compiler. I get the following result after building and running it. Enter a number: 6 k: 6 Enter a char: b: I just wanted to know if i can use char after int or not.
@PortfolioCourses2 жыл бұрын
I think what's happening is that after the user enters an integer like 5 they hit enter. Hitting enter is like entering a newline character. scanf() will "stop" at that new line character. Then the next time we call scanf() there is still a newline character on the "standard input buffer". And when we go to read in a char scanf() stops at that newline character. So I wonder if adding a space before the %c would fix it: scanf (" %c", &b); what that should do is "consume any whitespace characters" before reading in the next character using %c. I would try that and hopefully that works. :-)
@rezuwankabir33722 жыл бұрын
@@PortfolioCourses Thank you, It works this time.
@PortfolioCourses2 жыл бұрын
@@rezuwankabir3372 Excellent! 🙂
@depsylon4235 Жыл бұрын
as before, great video :) I was wondering, when you changed "n" from double to char couldn't you keep the %d, because char is just an 8Bit number and so even smaller than double.
@PortfolioCourses Жыл бұрын
Thank you! :-) I think I went from int to char with 'n'. And we could print a char with %d, but it would print "as a signed integer" so we would get a number like 65 in the case of the character 'A'.
@depsylon4235 Жыл бұрын
@@PortfolioCourses Ok I see, but could zou use the Integer type for the scanf and then print is as char ? (This is also not really about the practicability but rather if it would work, to help me better understand C) oh and Thanks for your reply
@PortfolioCourses Жыл бұрын
Yes, you could that. What you get when you "print as a char" would depend on the int entered, it might not be what you expect.
@NurettinSafak Жыл бұрын
I keep getting an error that says "Return value ignored: 'scanf'. and when I printf my variable it shows as a huge negative number
@PortfolioCourses Жыл бұрын
Hmm, it looks like some compilers/settings want you to check the value returned from scanf: stackoverflow.com/questions/10043841/c-error-ignoring-return-value-of-scanf. So maybe try storing the return value into a variable? The original code from this video is found here, in case that helps: github.com/portfoliocourses/c-example-code/blob/main/scanf.c. :-)
@vimwizard Жыл бұрын
bro tk u so much for the content
@PortfolioCourses Жыл бұрын
You’re very welcome!
@IsaacCode952 жыл бұрын
i have to put this macro at the top of my .c file #define _CRT_SECURE_NO_WARNINGS any reasons why, and tips on how to get rid of it ?
@PortfolioCourses2 жыл бұрын
At least in the case of Microsoft, secure versions of functions like scanf have been created, and _CRT_SECURE_NO_WARNINGS is a way of using the old insecure versions without getting compile warnigns: learn.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-170
@vandabiss Жыл бұрын
how do you run c programs with scanf on your mac? mine doesnt work :(( send help
@PortfolioCourses Жыл бұрын
You can use Xcode on a Mac: kzbin.info/www/bejne/iHTWl3eZq7d4sLc. :-) If you install Xcode, you can create and write C programs directly in Xcode. But if you install Xcode then you should also have the command-line gcc program installed as well, and you could access that program from the terminal and compile programs like in this video.
@ryanalnaser9142 жыл бұрын
whatever I do or did or anything or before or after
@kanakanakanakanameki2055 Жыл бұрын
Thank you so much!
@PortfolioCourses Жыл бұрын
You’re very welcome! :-)
@yalol85132 жыл бұрын
I have a question, why don’t we use the get_int or get_string function. Wouldn’t Scanf make it more complicated?
@PortfolioCourses2 жыл бұрын
Great question Ya! :-) The functions get_int and get_string are part of a library made by CS50, they aren't actually part of the C standard language. It's OK to use them to learn how to program, but they are not a part of the "official C language", where as scanf is part of the official C language.
@WaveStyleSlippy Жыл бұрын
@@PortfolioCourses So in the work field, do we only use the standard library? I’m starting confuse what I should learn now.
@PortfolioCourses Жыл бұрын
@@WaveStyleSlippy I'm not aware of projects in industry that use the CS50 library. My understanding is the CS50 provides a simplified library to help learners to understand how to program quicker and easier, sort of like "training wheels" for new programmers. In industry the standard library is used, but also many other libraries may be used as well. It's basically impossible to know all C libraries though because there are so many, what's most important is learning how to learn new libraries and figure out how they work. 🙂 The CS50 library is good for "learning" but I wouldn't suggest using it beyond that, though perhaps others have opinions as well.
@WaveStyleSlippy Жыл бұрын
@@PortfolioCourses Thank you for your opinion! I’m new in programming field and don’t really know how people properly do things. Your opinion gave me an idea what I should do next.
@PortfolioCourses Жыл бұрын
@@WaveStyleSlippy You're welcome! 🙂
@bardia-fs9ox Жыл бұрын
tnx man❤
@eqfrombc2 жыл бұрын
thanks!!
@PortfolioCourses2 жыл бұрын
You're welcome Erin! :-D
@generation6790 Жыл бұрын
why do you have to write the n=0 and not leave it as n; ?
@danilojonic Жыл бұрын
I think you can and it should be normal, same goes for char b; without adding 'a' He probably wants to show us that when scanf command is in use, int and char settings dont work (putting = random number on that int/char line)
@LukeEdward-p7v Жыл бұрын
is this still usable? or is it not up to date?
@PortfolioCourses Жыл бұрын
scanf hasn't changed much in 40 years really, it's still usable. :-)
@colonelh.s.l.38342 жыл бұрын
Hi! Is this video series just a more advanced version of kzbin.info/www/bejne/qaStimiDebGdotE ? How many hours worth is this playlist?
@PortfolioCourses2 жыл бұрын
Yes, essentially in this video series I just go into more detail on the topics discussed in the beginners course. This video series also covers many more topics than are covered in the beginners course. I'm not sure how many hours the entire video series is, but there are 144 videos total (at the time I reply to this comment) so there is a lot to go through. :-) This video series was created more so that people could pick out individual topics they are interested in learning more about, rather than something that must be watched entirely. There is also this other video playlist on C Programming Examples: kzbin.info/www/bejne/qZbTfGitabqYppI. :-)