Showing posts with label char string vs integer. Show all posts
Showing posts with label char string vs integer. Show all posts

Tuesday, 21 April 2015

char strings Vs Integers in C

simple program to demonstrate the inputting and displaying of character strings and integers in C


#include stdio.h
#include conio.h
#include string.h

void main(){
char name[15];
int age;

printf("enter name : ");
scanf("%s",name); // please note there is no & sign for char string

printf("enter age : ");
scanf("%d",&age); // note the & sign for the integer


printf("%s\t%d",name,age);

getch();

}//end of main


Result
char string Vs integer

Please note the & sign difference between char string and integer