A simple C code snippet that shows how to do a function call.

This simple C code snippet shows how to do a function call in C. This calls the hi() function and runs it in main(). Very simple but useful code. And this does not need to call any include files. As I am using the built-in write() function.

int hi()
{
        int i;
        i = 0;
 
        write(1, "Hi.\n", 5);
 
        while (i < 8) {
                system("echo 'This is a loop.'");
                i++;
        }
}
 
int main(int argc, char** argv)
{
        write(1, "Hello World\n", 15);
        hi();
 
        return 0;
}

No comments have been made. Use this form to start the conversation :)

Leave a Reply