Hello guys, how can I make the first character of a string is stored in a char?
example:

char [20]: "hello";
char c: h;

Recommended Answers

    char string[] = "Hello";
    char c = string[0];
    printf("%c",c);

Is this what you want ?

Jump to Post

All 2 Replies

    char string[] = "Hello";
    char c = string[0];
    printf("%c",c);

Is this what you want ?

// code for CodeBlocks

#include <iostream>
#include <string>

using namespace std;

int main()
{
  char string[] = "Hello";
  char c = string[0];
  printf("%c",c);
  return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.