-1

Using characters & strings, we normally write char{a,b,c,d} and string(a,b,c,d), what is the main difference between them, can we use them interchanging their positions?

4

string is a variable type defined by the CS50 library - it does not normally exist in C. Looking at the code for CS50.h will show this:

/*
 * Our own data type for string variables.
 */

typedef char *string;

This line could be read that a new type is defined, as a char *, called string. In other words, string is defined as exactly the same thing as a char *. They are identical and can be used interchangeably, so wherever you write char *, you can also write string.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .