I know I would first declare the input variable as char. But that just reads in the first letter of the word.
How can I print or read each letter of a certain word?
tquiva
7
Junior Poster in Training
Recommended Answers
Jump to PostCharacter array.
Jump to Posttry this
#include <stdio.h> #include <string.h> int main(void) { char myString[32]; int length, i; strcpy(myString,"Hello World!"); length = strlen(myString); for (i=0; i<length; i++) { printf("index %02d : %c 0x%02x\n", i, myString[i], myString[i]); } return 0; }
.
Jump to Postpointers.
Jump to Posttry this:
int main(void) { const char constString[32] = "Hello World!"; char *myPtr = &constString; while(*myPtr != '\0') { printf("address 0x%p: %c 0x%02x\n", myPtr, *myPtr, *myPtr); myPtr++; } return 0; }
All 15 Replies
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
jephthah
1,888
Posting Maven
tquiva
7
Junior Poster in Training
jephthah
1,888
Posting Maven
jephthah
1,888
Posting Maven
tquiva
7
Junior Poster in Training
hkdani
39
Posting Pro in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
tquiva
7
Junior Poster in Training
jephthah
1,888
Posting Maven
hkdani
39
Posting Pro in Training
tquiva
7
Junior Poster in Training
tquiva
7
Junior Poster in Training
Aia
1,977
Nearly a Posting Maven
hkdani
39
Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.