View previous topic :: View next topic |
Author |
Message |
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
Stucture initialization doesn't work for strings [SOLVED] |
Posted: Mon Dec 21, 2015 1:16 pm |
|
|
Hi,
Compiler: 5.025
This what I found.
Code: |
typedef struct
{
char* pc;
}cs;
cs cs_t= {"RIKO"};
//In main
printf("%s\n", cs_t.pc); |
Guess what, I get only new line character on the terminal. This compiler is a mess. _________________ A person who never made a mistake never tried anything new.
Last edited by rikotech8 on Tue Dec 22, 2015 4:10 am; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 21, 2015 2:24 pm |
|
|
It's your compiler version. It's too old. I compiled the following test
program with CCS vs. 5.051 and ran it in MPLAB simulator (MPLAB v8.92)
and it ran fine. It displays the following in the Output window:
If possible, you should upgrade your compiler.
Test program:
Code: |
#include <18F4620.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)
typedef struct
{
char* pc;
}cs;
cs cs_t= {"RIKO"};
//=====================================
void main()
{
printf("%s\n", cs_t.pc);
while(TRUE);
} |
|
|
|
rikotech8
Joined: 10 Dec 2011 Posts: 376 Location: Sofiq,Bulgariq
|
|
Posted: Tue Dec 22, 2015 2:59 am |
|
|
Yes you are right. I upgraded up to version 5.051 and it works now. _________________ A person who never made a mistake never tried anything new. |
|
|
|