Hey, I was just wondering if you guys could help me better understand this concept:
given:
Code:
int bubble(int a[], int n)
and:
Code:
int a[8] = {1,2,3,4,5,6,7,8}
we can invoke the bubble funtion by using:
Correct?
Now, if I have the user input a sting into a program such as:
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 this a correct way of calling a function and passing the string to it?
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.