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

Pointer to the middle of an array

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



Joined: 17 Oct 2005
Posts: 98

View user's profile Send private message

Pointer to the middle of an array
PostPosted: Fri Aug 01, 2014 6:13 am     Reply with quote

Hi forum,

I have a char array as ring buffer for receiving serial data.
I'm trying to locate some text in the buffer, so I would compare it to another array of char. I would use the strcmp function for comparison, and it takes pointers to the arrays, which is fine. But I don't want to start comparing from the beginning of the ring buffer array, so how do I create a pointer to someplace in the middle of the array?

Best regards,
Martin
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Aug 01, 2014 6:38 am     Reply with quote

POST your code!!
this is a practical forum -
not a blind debating society Very Happy Very Happy Very Happy
Futterama



Joined: 17 Oct 2005
Posts: 98

View user's profile Send private message

PostPosted: Fri Aug 01, 2014 6:47 am     Reply with quote

I just solved it myself, actually just by reading some regular C code example from here: http://www.eskimo.com/~scs/cclass/notes/sx10b.html

Code:
char array[] = {"This is a test"}; // The array with text data
char *ptr; // The pointer

ptr = &array[5]; // Set pointer to point at somewhere inside the array
printf("%c", *ptr); // Print the char from the array which the pointer points to


Sweet :-)
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