zwy12138 发表于 2017-5-1 09:40:37

为什么我显示"Undefined reference to WinMain@16"
#include<io.h>
#include<direct.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


#define MAX 256

long total;

int countLines(const char *filename);
void findAllCodes(const char *path);
void findAllFiles(const char *path);

int countLines(const char *filename)
{
        FILE *fp;
        int count=0;
        int temp;

        if ((fp=fopen(filename,"r"))==NULL)
        {
                fprintf(stderr,"Can not open the file:%s\n",filename);
                return 0;
        }
        while ((temp=fgetc(fp))!=EOF)
        {
                if (temp=='\n')
                {
                        count++;
                }
        }
        fclose(fp);
        return count;
}

void findAllCodes(const char *path)
{
        struct _finddata_t fa;
        long handle;
        char thePath,target;

        strcpy(thePath,path);
        if(( handle= _findfirst(strcat(thePath,"/*.c"),&fa))!= -1L)
        {
                do
                {
                        sprintf(target,"%s%s",path,fa.name);
                        total+=countLines(target);
                }while(_findnext(handle,&fa)==0);
        }

        _findclose(handle);
}

void findALLDirs(const char *path)
{
        struct _finddata_t fa;
        long handle;
        char thePath;

        strcpy(thePath,path);
        if ((handle= _findfirst(strcat(thePath,"/*"),&fa)) ==-1L)
        {
                fprintf(stderr,"The path %s is wrong!\n",path);
                return;
        }

        do
        {
                if(!strcmp(fa.name,".")|| !strcmp(fa.name,".."))
                        continue;

                if( fa.attrib==_A_SUBDIR)
                {
                        sprintf(thePath,"%s/%s",path,fa.name);
                        findAllCodes(thePath);
                        findALLDirs(thePath);
                }
        }while(_findnext(handle,&fa)==0);

        _findclose(handle);
}

int nain()
{
        char path=".";

        printf("Counting...\n");

        findAllCodes(path);
        findALLDirs(path);

        printf("So far you have typed %ld lines of codes!\n\n",total);
        system("pause");

        return 0;
}

zwy12138 发表于 2017-5-1 09:41:33

zwy12138 发表于 2017-5-1 09:40
为什么我显示"Undefined reference to WinMain@16"

好吧写成 nain了

rock5442107 发表于 2017-5-1 16:13:27

{:10_254:}{:10_254:}{:10_254:} 努力學習 ~

jyzhangjy 发表于 2017-5-2 20:14:09

学习xx

玩美主义 发表于 2017-5-3 11:48:59

么么哒小甲鱼

kai759630 发表于 2017-5-3 15:33:25

1

阿丶狸 发表于 2017-5-3 19:37:35

亲们趁敌人吃饭时发动进攻

dnfpk001 发表于 2017-5-4 10:35:07

# gcc le02.c -o le02 && ./le02
计算中。。。
目前你总共写了 121 行代码

dnfpk001 发表于 2017-5-4 11:00:05

计算中...
目前你总共写了 104 行代码

请按任意键继续. . .

您这是抢劫 发表于 2017-5-4 18:33:27

{:5_91:}

1031937775 发表于 2017-5-4 21:05:12

0、计算机只认识0 1

handai2008 发表于 2017-5-5 10:17:15

我做完了

lizhiyong_11 发表于 2017-5-5 11:02:49

我没有懂这个回什么贴

Loiker 发表于 2017-5-5 11:03:23

0

shadowsmile 发表于 2017-5-5 11:11:23

查看参考答案

柒叶枫露 发表于 2017-5-5 22:11:24

0.计算机只懂0和1
1.机器码
2.编译
3.编译型语言可以让计算机读懂,而解释型语言通过中间转换……?
4.不能
5.
6.

pirlo021 发表于 2017-5-6 12:48:46

1

-_Ailsa 发表于 2017-5-7 16:18:20

朕想知道

TerryCW 发表于 2017-5-8 21:58:13

哈哈

陌蚁 发表于 2017-5-9 21:13:54

本帖最后由 陌蚁 于 2017-5-9 21:15 编辑


页: 55 56 57 58 59 60 61 62 63 64 [65] 66 67 68 69 70 71 72 73 74
查看完整版本: S1E2:第一个程序 | 课后测试题及答案