I am confused by the difference between char, array of chars, char pointers and strings and when they should be used. I am ignoring String for now.
Here is a piece of FreeBasic code, that simply reads in several pairs of strings and puts them into two arrays. The first string is searched for and when matched, the second string is sent out a serial port.
[size=8pt][color=blue]// read in short description and corresponding SSC-32 command
Dim Move As String , CtrlrCmd As String;
Do While Not Eof(1)And ErrorFound =0 {
Input #1, Move, CtrlrCmd;
If UCase(Move) = "END" { Exit Do}
MoveIndex += 1;
ReDim Preserve MoveDescription(MoveIndex)As String, MoveCommand(MoveIndex)As String;
MoveDescription(MoveIndex) = UCase(Move);
MoveCommand(MoveIndex) = CtrlrCmd+cr;
}[/color] [/size]
How would this look in Arduino C? Anything like this?
[size=8pt][color=blue]// read in short description and corresponding SSC-32 command
char* MoveDescription[64][20];
char* MoveCommand[64][20];
char* Move[20];
char* CtrlrCmd[20];
Do While Not Eof(1)And ErrorFound =0 {
Input #1, Move, CtrlrCmd;
If UCase(Move) == "END" break
MoveIndex += 1;
MoveDescription[MoveIndex] = UCase(Move);
MoveCommand(MoveIndex) = CtrlrCmd+cr; // concatenation?
}[/color] [/size]
What about the differences between char, array of chars, char pointers and strings? I think I understand char vs array of char, but the other formats and their usages are not clear.