I have writtena function to display string of characters using pointer but it shows error. can anybody what is the error in it?
void WriteString(char *Buff) { int nStringLength; int nLoop; nStringLength = strlen(Buff); for(nLoop=0;nLoop<=nStringLength;nLoop++) { SBUF = Buff(nLoop); while(!TI); TI = 0; } Delay(50); return; }
when compiling there is a error pointing the line,
SBUF = Buff(nLoop); The error is,
Error C211 : call not to a function Error C208 'function':too many actual parameters.
My main function looks like below,
void main(void) { InitSerialPort(); WriteString("Control Genesis Power Supply"); WriteChar('m'); while(1); }
void InitSerialPort(void) { TMOD = 0x20; TH1 = 0xFD; // 19200 BAUD RATE TL1 = 0x00; SCON = 0x50; // SM0 = 0, SM1 = 1, REN = 1 TR1 = 0x01; // RUN CONTROL BIT }
After executing i can see only the character 'm' is coming in the serial port but the string is not coming.
I dont know whatis the problem. But this program runs fine with in the debugger/simulator mode.
As dan pointed it should be [ ] or alternately use SBUF= *Buff and Buff++