Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- char a[]={'a','b','c'};
- char *b[]={
- /*0*/"hello",
- /*1*/"abby",
- /*2*/"cheeze",
- /*3*/"ball",
- /*4*/"cats"
- };
- /* frist figure out how to get
- length of 2d array char*/
- int sc=0;
- for (int i=0;i<5;i++){
- sc=strlen(b[i]);
- printf("strlen *b[%d]=%lu\n",
- i,strlen(b[i]));
- }
- printf("\n");
- /* then figure out how to
- iterare the each word */
- for(int i=0;i<5;i++){
- sc=strlen(b[i]);
- for(int k=0;k<sc;k++){
- printf("%c ",b[i][k]);
- }
- printf("\n");
- }
- /* now figure out how to use
- a search string of a single
- char to find the matching
- letter in each word */
- /* get length of each word
- 2d char array*/
- for(int i=0;i<5;i++)
- {
- sc=strlen(b[i]);
- /* search pattern */
- for(int e=0;e<3;e++)
- {/* iterate each letter of
- word */
- for(int k=0;k<sc;k++)
- { /*check search pattern
- againt each each char
- in string */
- if(a[e]==b[i][k])
- {
- printf("\nfound %c=%c\n"
- "word is: %s\n",
- a[e],b[i][k],b[i]);
- }
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment