Joe
Joe

Reputation: 3089

problem with a function in c (linux)

I'm writing a C script to generate some sitemaps for some sections of my site. I'm trying to clean it up by moving a loop into a function that I can call instead of having several large loops on top of eachother in my script.

I'm not fluent in C by ANY means, I can work my way around it but functions are pretty confusing.

Here is what I'm trying to do:

    mysql_query(conn, qryListings);
    if((resultset2 = mysql_use_result(conn))) {
        write_to_sitemap(row2, resultset2);
    }

    void write_to_sitemap(MYSQL_ROW row2, MYSQL_RES* resultset2){
        while ((row2 = mysql_fetch_row(resultset2)) != NULL) {
            printf("    %s \n",row2[2]);
        }
    }

This is giving me the following errors: warning: conflicting types for âwrite_to_sitemapâ warning: previous implicit declaration of âwrite_to_sitemapâ was here

Can someone help me out?

Upvotes: 1

Views: 125

Answers (1)

Alnitak
Alnitak

Reputation: 339816

You just need to (pre)declare write_to_sitemap before its first use:

void write_to_sitemap(MYSQL_ROW row2, MYSQL_RES* resultset2);

or move its entire definition up in your file.

Upvotes: 2

Related Questions