Forum Discussion
Altera_Forum
Honored Contributor
13 years agoHelp in strings please
Hi, I'm having problems with using strings on NIOS II IDE. Basically I plan to connect a RFID reader in my DE2 board, RFID sends 12 characters so I made codes to read them one by one and then store i...
Altera_Forum
Honored Contributor
13 years agoIn general determine what the maximum number of characters your character array will hold and then add one more for the NULL character at the end of the string. More info: http://en.wikipedia.org/wiki/null-terminated_string
Often when working with a stream of data (characters being an example of that) the APIs you call will document what type of termination is needed. You require a NULL character at the end because printf doesn't know ahead of time how many characters are in 'message' when you are printing the entire string using %s. For the individual character printing the NULL character isn't needed because it already know how many characters to print when you use %c.