char in c code example

Example 1: how to create a string in c

char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
char greeting[] = "Hello";

Example 2: how to make a character in c

char key = 'A';

Example 3: como declarar uma string em c

char nome_cliente[61];

Example 4: declare string in c

char string[20];

Example 5: string in c

#include <stdio.h>
void displayString(char str[]);

int main()
{
    char str[50];
    printf("Enter string: ");
    fgets(str, sizeof(str), stdin);             
    displayString(str);     // Passing string to a function.    
    return 0;
}
void displayString(char str[])
{
    printf("String Output: ");
    puts(str);
}

Tags:

Css Example