My Profile

I, Das ShrikKrishna J. MCA III IMSCD&R, Ahmednagar.
Showing posts with label Print Character Using malloc. Show all posts
Showing posts with label Print Character Using malloc. Show all posts

Monday, 15 August 2011

Print Character Using malloc

Program in C to Accept a String from User and Print it Character by Character Using "malloc"
#include<stdio.h>
#include<conio.h>
void main()
{
int le=0,i=0;
char *pc="";
clrscr();
printf("Enter total number of characters\n");
scanf("%d",&le);
pc=(char*)malloc(le*sizeof(char));
printf("\nEnter a string of %d characters\n",le);
scanf("%s",pc);
printf("\nPrinting String Character by Character\n");
for(i=0;i<=le-1;i++)
{
printf("%c\n",*(pc+i));
}
getch();
}

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls