Wednesday, February 16, 2011

Managing Input and Output Operations

The program illustrates the function of %[ ] specification.
Program-A
#include <stdio.h>

void main()
{
char address[80];
printf("Enter address\n");
scanf("%[a-z ]", address);
printf("%-80s\n\n", address);
getch();
}

Program-B
#include <stdio.h>
void main()

{
char address[80];
printf("Enter address\n");
scanf("%[^\n]", address);
printf("%-80s", address);
getch();
}

No comments:

Post a Comment