[SOLVED] how to merge(concatenate) two or more char

Status
Not open for further replies.

jsbhalla88

Member level 1
Joined
Mar 3, 2015
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
314
hi.
i know this is simple but I am not able to do it..
I am reading characters from software UART, and storing them in char array. I acan only read one char at a time, so I am using char array.
now, I want to merge(concatenate) two/more characters from the array in which I received the char from UART.
I have tried using built in functions strncat, strcat..they should work.., but didn't in my case..
I am using MikroC pro for programming PIC18F45K22 microcontroller

can anyone suggest.?
 

Can it be that you didn't care for the difference between characters and null terminated strings? E.g. if you use strncat(), you still need a terminating null for the first string.
 

Just terminate the array with null character ('\0') and you will have a string. No need to concatenate.
 

thank you guys for the reply..
I tried to print the whole array with
Code:
Soft_UART_Write_Text(array_name);
and it worked..earlier I was using Soft_UART_Write();, it was printing just the first character.
and then used atoi() to convert to integer.. This what I needed to do..
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…