Code Competitions

Coding competition

Sunday, 26 May 2013

program to enter string using pointer and display on screen.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
    char *s,*p,a[20],i;
    i=0;
    s=&a[0];
    clrscr();
    while((*(a+i)=getchar())!='\n')
    {
        i++;
    }
    *(a+i)='\0';
    cout<<"entered string is accessed by array ";
    puts(a);
    cout<<"entered string is accessed by pointer ";
    puts(s);
    getch();
}

OUTPUT:
 

No comments:

Post a Comment