From NutWiki
Test Environments
|
| Nut/OS 4.6.4
|
| Ethernut 1.3 H
| OK [Binary]
|
| Ethernut 2.1 B
| OK [Binary]
|
| Ethernut 3.0 E
| OK [Binary]
|
| EIR 1.0 C
| Set jumper JP1 to DEBUG mode. [Binary]
|
|
| Compiler: ARM-GCC 4.2.2 ; AVR-GCC 4.3.0
|
|
Description
This example shows an easy and common way to store a string (e.g. for the application version) and printing it out.
Source Code
#include <dev/board.h>
#include <stdio.h>
int main(void)
{
char *version = "1.0";
u_long baud = 115200;
NutRegisterDevice(&DEV_DEBUG, 0, 0);
freopen(DEV_DEBUG_NAME, "w", stdout);
_ioctl(_fileno(stdout), UART_SETSPEED, &baud);
printf("Application version: %s\n", version);
for(;;);
return 0;
}
Output
Application version: 1.0
Details
defines a pointer to the type char, which points to an adress in memory where the string "1.0" is stored.
printf("Application version: %s\n", version);
now prints out the string stored at the adress, the version pointer provides.