In this tutorial I'll explain you how to get an input from the user in C language. You know that in most times I compare c with python. In python we have two functions called input() and raw_input() to get inputs. We could assign the input to a variable on the fly. However we can't use that way in C. Let's see some common methods we use in C.

Getch()

Studio.h header file contains this function's prototype. This function is used to get a single character from user. User may enter a characters using keyboard and program will catch it with this function.
#include<stdio.h> 

int main() { 	
  char ch; 	
  ch = getchar(); 	
  printf("your input was  : %c", ch); 
  return 0;
}
But in most of times we use this function to hold the screen on a position. Because when we call this function program waits for user input. So we can pause code execution till user enter something.
#include<stdio.h> 
#include<conio.h>  

int main() { 	
  printf("I'll wait until you enter anything\n")
  getchar(); 	
  printf("good bye! \n"); 
  return 0;
}

Gets()

Gets() function can get. String from user and copy it to a buffer.  This will copy all the user input until a meet null byte. You know that null byte is a string terminator. Gets function does not care about buffer space and how much is the length of given string. So using this function is dangerous. I have explained this situation in many places. If you are interested take a look at our protostar stack0 tutorial and stack & functions tutorial. Anyway it's important to know how we can use this function. First we have to declare a character array . This is the buffer space that string will get copied into. After that we can call gets function while supping a pointer to the buffer as an argument to function. Finally if we want we can print out that string using puts() or printf() function. Let's see an example.
#include<stdio.h> 

int main() { 	
  char buff[32]; 	
  gets(buff); 	
  puts(buff);
  return 0;
}
Hear , it is OK if input string is less than 32 bytes. But if it is bigger than that a located limit , it will lead to a buffer overflow. We will discuss more about this in exploit writing tutorials.  

Scanf()

This function is also used for getting inputs. Scanf() uses a syntax like printf() function. We can get the input to a character buffer. This function also not secure to use directly.  
#include<stdio.h> 

int main() { 	
  char buff[32]; 	
  scanf("%s\n", buff); 	
  puts(buff);
  return 0;
}

fgets()

All of above functions don't bound checking. So they may lead to buffer overflow vulnerabilities.  But fgets function has a limit and it don't copy a string more than the limited size. So this function is recommended to use in your codes.
#include <stdio.h> 
#define MAX 32 
int main() 
{ 
	char buff[MAX]; 
	fgets(buff, MAX, stdin); 
	printf("Your input was : %s\n", buff); 

	return 0; 
}
So that's all for this tutorial. C you again on next C programming tutorials.