Originally Posted by
laserlight
Why would you use an int array? For example, you might try reading into the int array using fscanf, but because the input is invalid for the type, you would get conversion failures. Or, you might try reading line by line using fgets, then parse the string using say, sscanf, but because the contents of the string is invalid for the type that you want to parse it as, you would get conversion failure.
In other words, if you intend on reading and writing to a file that has numbers and letters and you use an int array, then you are setting yourself up for failure... unless you somehow interpret the "numbers and letters" in a way that makes sense to populate an int array.
It depends on the value of the "literal number" and the range of values for char.
I recommend thinking about what you are trying to build, and deciding the data types depending on what you need to solve the problems that you set out to solve.
For example, if you are writing a program to play tic-tac-toe, then you need some kind of representation for the game grid that you can manipulate, so you concentrate on that. You don't have to actually store 'x' and 'o' in the grid. Rather, when you want to print the grid, you convert this internal representation to a string that can be printed. Likewise, you don't have to constrain your internal data structures to the input expected from the user, e.g., you could label the tiles on the grid with letters A to I, yet internally you convert these letters into integers (e.g., of type size_t) corresponding to indices of an array rather than characters (of type char).