const char [] and char[] difference question
-
Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:
const char strtest[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopthe output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:
char str123[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopThe output is only the first element: TTTTTTTT Any hint is appreciated.
-
Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:
const char strtest[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopthe output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:
char str123[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopThe output is only the first element: TTTTTTTT Any hint is appreciated.
focusdoit wrote:
char str123[] = "Test123\r\n"; //Global UART_print(strtest); //in a loop
Where is
str123
used? What is the signature ofUART_print()
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:
const char strtest[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopthe output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:
char str123[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopThe output is only the first element: TTTTTTTT Any hint is appreciated.
-
Hi, I wrote a small c program on a microcontroller, 32bit. I met a weird problem. I wrote code like:
const char strtest[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopthe output is fine, I can see the output on Teraterm(RS232 interface tool), like: Test123 Test123 .. But when I try code:
char str123[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopThe output is only the first element: TTTTTTTT Any hint is appreciated.
focusdoit wrote:
But when I try code:
char str123[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopYou defined the variable str123 but you print the strtest. Where and how is this strtest defined?
-
focusdoit wrote:
But when I try code:
char str123[] = "Test123\r\n"; //Global
UART_print(strtest); //in a loopYou defined the variable str123 but you print the strtest. Where and how is this strtest defined?