Aug 12, 2019

Outputs in C

In C there are number of ways to getting output to the screen.You can use them according to your needs. Let's see one by one. Printf This function is the most used one in C to print a string. In both of previous tutorials we saw how to use this function. printf("welcome to HacksLand\n"); You need to give a string as the argument for this function. Actually a string is a character array .So giving a string to this function what we do is give the address of first character of string. I don't talk any deep contents about arrays or strings, because we'll discuss them in separate tutorials. Did you notice a \n at the end of our string? Why we use it.

#include <stdio.h>
int main(){
  printf("welcome to hacksland\n");
  return 0;
}

Printf function is defined in stdio.h header file. That's why we included that file before use printf. Let's compile and run above file.

printf in C

Putchar() This is another function for printing. But using this Putchar you can print only a one character .This function is used rarely. Anyway let's see how to use it.

#include <stdio.h>

int main () {
   char ch[] = 'a';
   putchar(ch);
   return(0);
}

I think this is enough for this tutorial. In next tutorial we are going to learn how to get inputs from user and how to combine it with printf. C you again. :-)

Aug 20
SQL injection example

Hello guys, In a previous tutorial I explained basic theories about SQL injection. In there we....

Jun 16
Remote Command Execution

How are you guys, I hope you are enjoying our site. Did you read sqli tutorials and xss....

Sep 23
Function prologue and the stack

Prologue is the process that build a stack frame for a function. The compiler is responsible about....

Replying to 's comment Cancel reply
CATEGORIES
ABOUT AUTHER
Thilan Danushka Dissanayaka

Thilan Dissanayaka

Hi, I'm Thilan from Srilanka. An undergraduate Engineering student of University of Ruhuna. I love to explorer things about CS, Hacking, Reverse engineering etc.

SOCIAL
RANDOM ARTICLES