Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Stick it in a while loop with the expression: while(*ptr2 != 0)
print out each character at a time and then increment the pointer, inside the loop. A bit like:
printf("%c", *ptr2++);
Might I add, your string must end with a null character (0 in decimal) with the above technique, otherwise you will end up printing data from other areas of memory.
Another (likely safer) way is to have an integer variable called a_length, with the number of characters specified explicitly.
Then you print and increment the pointer inside a "for" loop until all the characters have been iterated.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.