I think that Tride wants you to explain it in simpler terms, he is a beginner after all, and frankly, I think your answers are too complicated for him (you are using loops and arrays, and he still doesn't understand char's) to understand completely. I will try and explain it as simple as possible.
A char is a variable (the smallest kind) and it just happens to be that this variable holds text (also called strings). Its that simple. With this variable you can make a program 'store' or 'hold' the text "James", this variable is called a char because it is in text. A char could also be a single character, for example 'f'. Before you can assign a value to any char (its the same with all variables), you need to declare at the beginning of main. Here is an example of declaring a char varible named letter that holds the 'g' character:
Code:
#include <stdio.h>
int main()
{
char letter = 'g';
..................
You have to put single quotes ' ' when referring to a single character. Remember you don't always have to give a 'value' (a letter) to char, you can just declare it, and give the value later in the program. Example:
Code:
#include <stdio.h>
int main()
{
char letter;
......................
All the examples above have been of char's variables that can only 'hold' 1 character, but (as stated before) you can also use them to 'store' a word or more. In that case you have to declare them a little different, you do the same but you have to specify the number of memory (each letter takes 1 byte, so if you have 6 characters you would have to put 7, just add 1 to the number of characters (yes, a space is also a character). I know it is a little confusing but just for now follow me and learn this, you will later learn why exactly this happens). Here is an example of declaring a char variable to 'store' more than 1 character (in this case 19):
Code:
#include <stdio.h>
int main()
{
char words[20];
......................
You could also give tell the variable what to store right away. Example:
Code:
#include <stdio.h>
int main()
{
char words[] = "I am the best";
......................
In this case, you have to put in double quotes " " the text you want the varible to store. You also don't have to specify the number of characters in the text, the compiler does that automatically (you still have to put the [] ).
Now that you now how to declare a char variable, I'll put an example of a use for the char variable. Example:
Code:
#include <stdio.h>
int main()
{
char letter = 'h';
char word[] = "Bond, James Bond";
printf("The letter variable is holding %c, and the word variable is holding %s.",letter,word);
return 0;
}
This simple program displays the 'characters' that each char variable is holding. The printf function displays text, and also variables, in this case char. But you have to specify what variable type it is supposed to display. If you have a char holding a simple character you put %c to tell the printf function to display the variable there, and if you have a char holding more than 1 character you put %s. But also have to specify which variable is supposed to be displayed, so you put at then end of printf, a comma , and the varible name (or names if you want to display more than 1 variable in a printf statement). I just explain it here so you can understand better, but I assume you already know what a printf function does.
Now to sum all up, a char variable stores text, whether a single character or many. When you store more than 1 character in a char variable, it is called an array, a char array. Remember you don't have to memorize it all, it is just meant for you to understand better, you will get it as you start learning more C. Good luck!