I am writing a C-code to use in PIC 18 micro-controller using MPLAB IDE. I have 5 strings and I want to be able to use pointers. The idea is having an array containing the pointers to the string arrays. and have them print on the console. The code below compiles with No errors or warnings, but all I get on the console is garbage.
Can someone point me to the right direction. many thanks. sorry if my formatting of the code is not right.
#include <stdio.h>
#include <p18f4520.h>
#include <stdlib.h>
#pragma config WDT = OFF
#define size 64
#pragma romdata s1=0x300 //specific ROM addresses for the data
rom char *s1[] = "Hello";
#pragma romdata s2 = 0x307
rom char *s2 = "Welcome to C programming";
#pragma romdata s3=0x31A
rom char *s3= "My name is ";
#pragma romdata s4=0x32C
rom char *s4 = "Pic18 program";
#pragma romdata s5=0x33A
rom char *s5 ="Goodbye, I hope this works!";
void printString(const char*);
void main (void)
{
int i=0;
char stringArray [] = {*s1, *s2, *s3, *s4, *s5};
char *ptr=stringArray;
while(i<5)
{
printString(&ptr[i]);
i++;
}
}
void printString( const char *strPtr)
{
while(*strPtr !='\0')
{
printf("%c", strPtr);
strPtr++;
}
}
`