C Programming Fundamentals - Input
Key Takeaways
This video covers the fundamentals of user input in the C programming language, a crucial aspect of cybersecurity and exploit development.
Full Transcript
[Music] hey guys hackersploit here back again with another video and welcome back to the c programming series in this video we're going to be looking at input more specifically user input so in the previous video we took a look at variables and functions and now it's time to take a look at how to essentially get a user to input their data and how we can use that data uh in various ways all right so uh when it comes down to the c programming languages there are various ways you can get your data into the system or there are various ways you can use uh to essentially get the user to input the data now uh the two of the ways that i sort of prefer are the gets inputs or you have your printf and scanf which is probably the the most preferred so let's get started with looking at how to input an integer or a number for that matter so the first thing i'm going to do is i'm just i'm just going to include my standard library here so uh include and i'm just going to type in stdlib.h right over here and we'll close that out and we want to include this uh the ink we want to include uh the input output library uh stdlib dot um sorry the stdio.h sorry about that guys and we're ready to begin all right so we have a spelling mistake right over here and we should be ready all right so when you're talking about input we're just going to create a simple program that will uh prompt the user to input a number and once they've input the number the uh the the program will essentially print out the number that the user inputted all right so we're going to say something like uh in we're going to create our main function here no arguments yet all right so we're going to create a variable here and let's just let let's just call the variable age we're not going to initialize it with any very with any value so we're going to say uh we're not going to prompt the user to enter the data so we're going to say please uh please enter your age all right and we'll use a nice little colon over there and we'll give it a space so that the user can actually enter their data with some spacing all right so now we can uh for for this purpose let's start off with using the uh the printf and scanf which is the best for integers in my opinion so we use the scanf and then here right over here because we are actually uh we're we are now inputting the data into the system we need to specify what type of data it is and uh if you remember the previous video when we're talking about inputting or printing out data uh we need to specify the type of data in this case it's a decimal so uh again uh this applies to integers floats doubles etc so we are going to specify that so this is a decimal and we are going to save it into the variable h all right so the value that the user enters will be saved into the into the variable h but one interesting thing is is you if you are going to save uh if you are going to save the value being entered into a variable you need to use the uh for an integer only you need to use the and symbol right over here just before the um just before the variable name all right so uh we've essentially inputted the data now and it is going to be stored into the age variable so we can essentially at this point print it out to to the user so we can say you you can just say your age is um and we can give it a nice little uh colon right over there and again we specify the data that we are um the data that we're outputting in this case and we remember remember the syntax a comma and the name of the variable but in this case we do not need the uh the and symbol there and once that is done we will um essentially return uh zero here just to make sure that the that everything run correctly within the main function so i'm going to rebuild all here and once it's compiled i'm just going to run it here and it's going to ask me to enter my h i'm just going to enter an age of maybe 40 for example uh so 40 and we hit enter and there we are it tells us your age is 40. pretty simple now things get a little bit complex when you move on to characters because we need to specify quite a bit of stuff i'll show you this right now so the other way you can go about uh inputting data is using the get and put all right so the get input really works very very simply so i'll show you this and this case will start we will be using a string or the char uh data type all right so um so in this case we'll move on to name so what i'm going to do is i'm just going to create a um a character variable here hr variable of course it's going to be a string and i'm just going to call it name and this will have we can give it a nice amount of space so we'll say 20 for example and now we will print uh we'll prompt the user rather so we're going to say print uh printf i'm going to say uh please um enter your name all right and again we'll provide the need the necessary punctuation there so printf please enter your name and now we use the get or the gets as it would be called we use gets to essentially uh save the value that is inputted into the variable so we say gets and in here so we put the variable that that we're going to be using in this case we'll just type in name and again remember to use the semicolon all right so now what we need to do is we can now print out the data so we can say uh we can say print printf and we say you have entered and then after this we then specify we can actually break to the next line here but in this case we'll just leave it on the single line and then we get we say puts and we specify the variable name right over here and that should save it to the variable itself and print it out and uh once this that is done we can use the return zero to see what uh to essentially test if we have any errors or rebuild all no errors at all and we're going to run this enter your name i'm just going to enter lexis and there we are it's going to tell me you have entered the lexus fantastic so we also see that it also gave us a return value of 0 which means it executed correctly all right so that is how to use get and put now i really do not prefer using this way i like using the scan f and printf which is probably my my favorite way of going about it now when we talk about we've already taken a look at essentially inputting inputting integers uh with the scanf now if we talk about using strings or characters uh with printf it really does have a different type of syntax so i'll show you this uh right now so what we can do is uh we will just leave the variable name as it is we don't we do not need to initialize anything else uh so essentially what what would happen here is we would prompt the user to enter their name so printf and we say please uh sorry about that we need a double quotation marks here so we just print up please uh enter your um your name and we'll specify that like so now if you want to break to the uh to a next line you can always use the n command right over there uh sorry the back slash and the n uh and the end key all right so now we are using the scanf but again as i mentioned it's going to be very different so we can say scan f and then with uh inside of uh here we then specify again uh the type of data that's being entered in this case we're entering a string so s and then after this is where we would specify uh the name of the variable that we're talking about so that is going to be name all right so after that after after we've entered the name or or the variable that you're using we then need to print out the data so printing out is really very simple as i mentioned so make sure we use the semicolon right over there so we are now going to say uh printf printf right over here and we're going to say you entered your name is we can just say your name is i was going to just say your name is like so and after this we use the format uh remember it's always very important to uh to specify that and finally uh we use the variable name right over here and we close that off with a semicolon and we return the value of zero just to make sure everything run correctly and we rebuild all all right so that run without any errors whatsoever and we're gonna hit run so it's gonna prompt me to enter my name i'm just gonna enter a different name apart from my name john and there we are your name is john all right so that is pretty much how to get data in into the system and uh pretty pretty interesting you can go about it two ways as i've just mentioned there is another way but uh pretty much these uh the these two methods are my personally are my favorite and the most efficient now before we actually go let me create a simple script that allows the user to essentially input their name and age all right so we will create another variable here and we'll call it in age and into edge we're not going to assign any value all right so it's going to um it's going to ask the user to enter the name and they're going to enter their name and they're going to say printf please enter your age so uh please i'm sorry about that please enter your age please enter your age and we're gonna break that right over there and scanf and remember we need to specify the type of data that's being input in this case it's a decimal all right so and then we're going to specify the variable there and but remember in this case we have to use the uh the and symbol if data is being input in the system and we hit enter and after this we can start printing out the data now of course in this case we would need to break the line because we want to display on our different lines so in over right over here i will just break the line like so and i'll print uh i'll print this in the uh in the second line with the different values so printf sorry we do not want to do it indent that so you can then say your uh your age your age is and we specify the data here it is not a string definitely and the value is going to be of age right over here all right so that pretty much should print out the data that we're looking for and of course it's going to go to the next line so let us see how this actually pans out so i'm going to execute i'm going to rebuild all sorry compile it and we're going to run it and it's going to ask me for my name now so i'm going to just uh enter different names i'm just going to john one more time and john is 120 years old i'm gonna hit enter there we are your name is john and your age is 120. all right so that is how to get different types of data into your system and again if you wanted to know that's how to get different data types of data out of your system so input and output in the c programming language all right so that's going to be it for this video guys thank you so much for watching if you have any questions or suggestions let me know in the comments section on my social networks or on my website and i'll be seeing you guys in the next video peace you
Original Description
Hey guys! HackerSploit here back again with another video, in this video, I will be explaining user input in the C programming language.
⭐Help Support HackerSploit by using the following links:
🔗 NordVPN: https://nordvpn.org/hacker
Use the link above or the code below for 77% Off your order
Promo Code: hacker
Patreon: http://patreon.com/hackersploit
I Hope you enjoy/enjoyed the video.
If you have any questions or suggestions feel free to ask them in the comments section or on my social networks.
🔗 HackerSploit Website: https://hsploit.com/
🔹 Support The Channel
NordVPN Affiliate Link: https://nordvpn.org/hacker
Patreon: http://patreon.com/hackersploit
🔹 Get Our Courses
Get a special discount on our courses:
The Complete Deep Web Course 2018:
https://www.udemy.com/the-complete-deep-web-course-2017/?couponCode=DWCBP2017
🔹 SOCIAL NETWORKS - Connect With Us!
-------------------------------
Facebook: https://www.facebook.com/HackerSploit/
Twitter: https://twitter.com/HackerSploit
Instagram: https://www.instagram.com/hackersploit/
Patreon: http://patreon.com/hackersploit
--------------------------------
Thanks for watching!
Благодаря за гледането
Kiitos katsomisesta
Danke fürs Zuschauen!
感谢您观看
Merci d'avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة
دیکھنے کے لیے شکریہ
देखने के लिए धन्यवाद
#Hacking#C#ExploitDevelopment
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from HackerSploit · HackerSploit · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How To Install Kali Linux 2.0 On Virtual Box
HackerSploit
100 Subscriber Q&A! - How I Learned Ethical Hacking
HackerSploit
BlackArch Linux Review - Better Than Kali Linux?
HackerSploit
How to Access the Deep Web Safely | Deep Web Starter Guide 1.0
HackerSploit
Wireshark Tutorial for Beginners - Installation
HackerSploit
Wireshark Tutorial for Beginners - Overview of the environment
HackerSploit
Wireshark Tutorial for Beginners - Capture options
HackerSploit
Wireshark Tutorial for Beginners - Filters
HackerSploit
Complete Ethical Hacking Course - Become a Hacker Today - #1 Hacking Terminology
HackerSploit
Complete Ethical Hacking Course #2 - Installing Kali Linux
HackerSploit
Parrot OS 3.5 Review | The Best Kali Linux Alternative
HackerSploit
Nmap Tutorial For Beginners - 1 - What is Nmap?
HackerSploit
Katoolin | How To Install Pentesting Tools On Any Linux Distro
HackerSploit
Nmap Tutorial For Beginners - 2 - Advanced Scanning
HackerSploit
Nmap Tutorial For Beginners - 3 - Aggressive Scanning
HackerSploit
Zenmap Tutorial For Beginners
HackerSploit
How To Setup Proxychains In Kali Linux - #1 - Stay Anonymous
HackerSploit
How To Setup Proxychains In Kali Linux - #2 - Change Your IP
HackerSploit
How To Change Mac Address In Kali Linux | Macchanger
HackerSploit
How To Setup And Use anonsurf On Kali Linux | Stay Anonymous
HackerSploit
Ubuntu 17.04 "Zesty Zapus" Review - Bye Unity
HackerSploit
VPN And DNS For Beginners | Kali Linux
HackerSploit
Tails OS Installation And Review - Access The Deep Web/Dark Net
HackerSploit
Steganography Tutorial - Hide Messages In Images
HackerSploit
The Lazy Script - Kali Linux 2017.1 - Automate Penetration Testing!
HackerSploit
Best Linux Distributions For Penetration Testing
HackerSploit
Netcat Tutorial - The Swiss Army Knife Of Networking - Reverse Shell
HackerSploit
Gaining Access - Web Server Hacking - Metasploitable - #1
HackerSploit
Web Server Hacking - FTP Backdoor Command Execution With Metasploit - #2
HackerSploit
How To Install Kali Linux On VMware - Complete Guide 2018
HackerSploit
Q&A #1 - Best Cyber-security Certifications?
HackerSploit
Terminator - Kali Linux - Multiple Terminals
HackerSploit
Shodan Search Engine Tutorial - Access Routers,Servers,Webcams + Install CLI
HackerSploit
Q&A #2 - Mr Robot?
HackerSploit
Metasploit Community Web GUI - Installation And Overview
HackerSploit
Linux Expl0rer - Forensics Toolbox - Installation & Configuration
HackerSploit
QuasarRAT - The Best Windows RAT? - Remote Administration Tool for Windows
HackerSploit
Metasploit For Beginners - #1 - The Basics - Modules, Exploits & Payloads
HackerSploit
Metasploit For Beginners - #2 - Understanding Metasploit Modules
HackerSploit
Kali Linux Quick Tips - #1 - Adding a non-root user
HackerSploit
Metasploit For Beginners - #3 - Information Gathering - Auxiliary Scanners
HackerSploit
Spectre Meltdown Vulnerability - How To Check Your System
HackerSploit
Metasploit For Beginners - #4 - Basic Exploitation
HackerSploit
ARP Spoofing With arpspoof - MITM
HackerSploit
WordPress Vulnerability Scanning With WPScan
HackerSploit
Generating A PHP Backdoor with weevely
HackerSploit
Nikto Web Vulnerability Scanner - Web Penetration Testing - #1
HackerSploit
How To Install Kali Linux On Windows 10 - Windows Subsystem For Linux
HackerSploit
Stacer - System Optimizer And Monitoring Tool For Linux
HackerSploit
Kali Linux 2018.1 - Kernel Updates & Patches
HackerSploit
MITM With Ettercap - ARP Poisoning
HackerSploit
Password Cracking With John The Ripper - RAR/ZIP & Linux Passwords
HackerSploit
How To Detect Rootkits On Kali Linux - chkrootkit & rkhunter
HackerSploit
Channel Updates - How To Post Questions & Video Suggestions
HackerSploit
Web App Penetration Testing - #1 - Setting Up Burp Suite
HackerSploit
Web App Penetration Testing - #2 - Spidering & DVWA
HackerSploit
Cl0neMast3r - GitHub Repository Cloning Tool
HackerSploit
Kali Linux On Windows 10 Official - WSL - Installation & Configuration
HackerSploit
DoS/DDoS Protection - How To Enable ICMP, UDP & TCP Flood Filtering
HackerSploit
Web App Penetration Testing - #3 - Brute Force With Burp Suite
HackerSploit
More on: Security Basics
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
eCPPTv3 Review
Medium · Cybersecurity
Next-Gen Endpoint Protection Software: Securing Remote Employees Against Modern Cyber Threats
Medium · Cybersecurity
Understanding NAT (Network Address Translation): How Multiple Devices Share a Single Public IP…
Medium · Cybersecurity
Why the EC-Council 312-41 Practice Test Is Essential for Certification Success
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI