How to print char in C and C++

Du bist neu in der Welt von C++? Dann schau hier herein!
Antworten
roxijan2
Beiträge: 1
Registriert: 21. Juni 2022 12:44

How to print char in C and C++

Beitrag von roxijan2 »

In this article, I am going to show you how to print the character in C. The first step is to get your character. For this, you have to use the char function which returns a pointer to a character. Next, we need to print it on screen:
how make a character in c scanf

Code: Alles auswählen

scanf(" %c", &c);
c print char

Code: Alles auswählen

char bob = 'X';
printf("%c", bob);
putchar(bob);
c printing char pointer

Code: Alles auswählen

#include <stdio.h>

int main()
{
char * str = "Hello";
printf("%s\n", str);

return 0;
}
C Print Characters

Code: Alles auswählen

#include <stdio.h>
int main()
{
    char chr = 'a';    
    printf("character = %c", chr);  
    return 0;
}
Antworten