CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Stucture initialization doesn't work for strings [SOLVED]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

Stucture initialization doesn't work for strings [SOLVED]
PostPosted: Mon Dec 21, 2015 1:16 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 21, 2015 2:24 pm     Reply with quote

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:
Quote:
RIKO

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

View user's profile Send private message

PostPosted: Tue Dec 22, 2015 2:59 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group