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 CCS Technical Support

Arrays and pointers

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



Joined: 19 Jun 2007
Posts: 4

View user's profile Send private message

Arrays and pointers
PostPosted: Tue Jun 19, 2007 7:46 am     Reply with quote

I have some problem about the character string to serial transmission with RS232. I use the PIC16F877 and in the book "Embedded C Programming and the Microchip PIC" of THOMSON (written by Barnett, Cox & O'Cull) to pg. 49 there is an example about the character string.
I would know the reason because on video I show:
" This is a test  / "
Below, I write the code:


#include <16F877.h>
#fuses HS
#use delay(clock=20000000)
#use rs232(baud=9600, parity=N, xmit= PIN_C5, rcv=PIN_C7,stream=, bits=8)
#include <stdio.h>

void main()
{
char i;
char *p;
const char s[15] = {"This is a test"};

for(i=0; i<15; i++) putchar(s[i]);
p = s;
for(i=0; i<15; i++) putchar(*p++);
}
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Tue Jun 19, 2007 7:51 am     Reply with quote

The compiler does not allow pointer to constants.

try with char s[15] = {"This is a test"};
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