开发者

problem with a function in c (linux)

开发者 https://www.devze.com 2023-02-19 00:47 出处:网络
I\'m writing a C sc开发者_开发百科ript 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 lar

I'm writing a C sc开发者_开发百科ript 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消