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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.