Thank you inadvance. I apologise if my question is stupid!
I am trying to use user defines functions and my test code actually works but I get warning erros which I do not understand:. The warning errors are as follws:
my_array.c: In function 'main':
my_array.c:24:5: warning: implicit declaration of function 'myarray' [-Wimplicit-function-declaration]
myarray(i);
^~~~~~~
my_array.c: At top level:
my_array.c:50:1: warning: return type defaults to 'int' [-Wimplicit-int]
myarray(i)
^~~~~~~
my_array.c: In function 'myarray':
my_array.c:50:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int]
My code is:
#include <stdio.h>
#include <unistd.h> // For sleep function
// Function prototype (declaration)
void countDown(int initialValue);
void countUp(int baseValue);
int main() {
int y = 11;
int x = 0;
int i=0;
// char ponumarray[12] [12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
// Call the user-defined function
countDown(y);
printf("\n\n");
// Call the second user-defined function
countUp(x);
// Call the third user-defind function
myarray(i);
return 0;
}
// Function definition
void countDown(int initialValue)
{
while (initialValue > 1) {
sleep(1); // Wait for 1 second
initialValue--;
printf("%d ", initialValue);
}
}
void countUp(int baseValue)
{
while (baseValue < 10) {
sleep(1); // Wait for 1 second
baseValue++;
printf("%d ", baseValue);
}
}
myarray(i)
{
printf(" \n\n");
i=0;
char ponumarray[12] [10] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
printf ("String array elements are:\n\n");
printf(" \n");
//for (int i=0; i <13; i++)
while ( i < 12) {
sleep(1);
printf("%s\n", ponumarray[i]);
i++;
}
return(0);
}