getch() pic

Status
Not open for further replies.

neelam29

New Member
hi all
want to read a string of message from modem to pic16f877
scanf isnt working.i think i will have to use getch();
can anybody help me out for how to use this function. i want to recive the message "hello" which my gsm has transmitted to pic.

how will it come to know that the string has ended and what is the method to use this getch() function?
 

hi,
I dont use C, but a Google for 'getch() function' gave lots of hits.

**broken link removed**
 
getch() does as defined - get one char, and you need an array to build your string 'hello,' which will be terminated with the nul char \0. You will need an array big enough to hold your string, plus one more bite for the nul, so to hold 'hello' you need myString[5] Don't forget that an array begins at 0, not 1, so
declare a byte as an index and loop through your array using something like:
while myString[index] not equal to '\0'
myString[index] = getch()

You should end up with something like: myString[0] = 'h', myString[1] = 'e' ... myString[5] =' \0'

edited for clarity
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…