Hey, I was just wondering if you guys could help me better understand this concept:
given:
and:Code:int bubble(int a[], int n)
we can invoke the bubble funtion by using:Code:int a[8] = {1,2,3,4,5,6,7,8}
Correct?Code:bubble(a,8)
Now, if I have the user input a sting into a program such as:
Is this a correct way of calling a function and passing the string to it?Code:#define MAXSTRING 100 void word_cnt (char a[], int n) // not sure if that is correct// int main(void) { char c, a[MAXSTRING]; int i; printf("\nPlease enter your favorite string. "); for(i = 0,(c = getchar()) != '\n'; ++i){ a[i] = c } a[i] = '\0'; word_cnt(a,MAXSTRING) }
Is it silly to use a function and not just count the words in main(void)?
I'm also not sure how to count through the characters in a string in another function.



LinkBack URL
About LinkBacks


