Wednesday 2 July 2014

C++ program to print string using pointer


Here is a C++ program to print string using pointer


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    char x[10]={"Computer"},*p;
    p=&x[0];
    cout<<"String : ";
    while(*p!='\0')
    {
        cout<<*p;
        p++;
    }
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment