As a fairly new student in C I am having diffictly with arrays. I have a string of numbers that I am tring to split up into smaller strings to convert them to integers. I have made the code as basic as possible but still get the errors.
#include <stdio.h> #include <stdlib.h> #include <reg52.h> xdata char Temperatures1[9]; xdata char Temperatures2[12]; xdata char Temperatures3[9]; void main(void) { char a[36] = "<<123456789012345678901234567890>>"; int s; SCON = 0x52; TMOD = 0x20; TCON = 0x69; TH1 = 0xF5; for(s=0; s < 9; s++) { Temperatures1[s] = a[s+2]; } for(s=0; s < 12; s++) { Temperatures2[s] = a[s+11]; } for(s=0; s < 9; s++) { Temperatures3[s] = a[s+23]; } printf("Temperatures1: %s\n", Temperatures1); printf("Temperatures2: %s\n", Temperatures2); printf("Temperatures3: %s\n", Temperatures3); }
The 'C' initializer will probably clear the arrays before calling main() The C language requires this. All static duration variables must be zeroed before main is called.