Defines a string literal and uses it twice. - C++ Data Type

C++ examples for Data Type:char array

Description

Defines a string literal and uses it twice.

Demo Code

#include <iostream>
using namespace std;
#define MYNAME "test test"
int main()/*from  w ww  . ja  v a2  s  . c  om*/
{
   char name[]=MYNAME;
   cout << "My name is " << name << "\n";   // Prints the array.
   cout << "My name is " << MYNAME << "\n"; // Prints the
   // defined literal.
   return 0;
}

Result


Related Tutorials