Answers for "#of chars c++"

C++
0

how to create an array of char in c++

// strings and NTCS:
#include <iostream>
#include <string>
using namespace std;

int main ()
{
  char question1[] = "What is your name? ";
  string question2 = "Where do you live? ";
  char answer1 [80];
  string answer2;
  cout << question1;
  cin >> answer1;
  cout << question2;
  cin >> answer2;
  cout << "Hello, " << answer1;
  cout << " from " << answer2 << "!n";
  return 0;
}
Posted by: Guest on June-04-2020
1

c++ char define

// syntax: 
// char <variable-name>[] = { '<1st-char>',  '<2nd-char>', ... , '<Nth-char>', ''}; 

// example (to store 'Hello' in the YourVar variable): 
char YourVar[] = {'H','e','l','l','o',''}; // NOTE: the  marks the end of the char array
Posted by: Guest on April-29-2020

Browse Popular Code Answers by Language