刘氓 发表于 2018-8-8 09:40:13

dereferencing pointer to incomplete type
出现了这个提示,目前还未解决

CCCFC 发表于 2018-8-8 10:32:00

1

CCCFC 发表于 2018-8-8 10:56:36

写代码的时候左边会显示写的行数?

329759546 发表于 2018-8-8 11:19:32

1.因为cpu智能识别0.1
2.0.1
3.编译
4.可以
5.翻译器

329759546 发表于 2018-8-8 11:23:14

为什么我是110行我自己输入和复制粘贴都是110

wlchcarl 发表于 2018-8-8 14:35:40

看看答案

洛必达灬定理 发表于 2018-8-8 15:25:44

我就看看那个摩斯密码

王梓轩 发表于 2018-8-8 15:35:02

HAHAHA

zzjlovezzs 发表于 2018-8-8 18:42:51

{:9_221:}

zxp0811 发表于 2018-8-8 21:21:11

{:5_109:}

xiaodoubi 发表于 2018-8-8 22:30:23

1111

沉默失金 发表于 2018-8-9 00:22:12

11111111111111

LSForever0 发表于 2018-8-9 00:28:22

0.因为计算机只懂得0和1
1.机器语言
2.编译
3.\
4.不能
5.通过解码器
6.\
7.QINMENCHENDIRENCHIFANSHIFADONGJINGONG
亲们趁敌人吃饭时发动进攻

LSForever0 发表于 2018-8-9 01:39:58


#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 main()
{
        char path = ".";
       
        printf("¼ÆËãÖD...\n");
       
        findAllCodes(path);
        findALLDirs(path);
       
        printf("ĿǰÄã×ü12D′áË %ld DD′úÂë!\n\n", total);
        system("pause");
       
        return 0;
}




显示出错是什么情况
C:\Users\zzbo9\AppData\Local\Temp\cccFww9i.o        试一试.c:(.text+0x147): undefined reference to `countLines'
G:\FishC\S1e2\collect2.exe        ld returned 1 exit status

LSForever0 发表于 2018-8-9 02:21:17


对照了一下,发现了好多错,但还是完成了!

AastaLee 发表于 2018-8-9 13:58:05

本帖最后由 AastaLee 于 2018-8-9 15:03 编辑

0. 只懂二進制的0和1
1. 機器語言
2. 編譯
3. 編譯型語言做出來的機器瑪可以直接被CPU執行 解釋型語言寫出來的字節碼需要被解釋氣解釋後才能被CPU執行
4. 否
5.
6.
7.翻譯出來了看不懂...

一直顯示總共寫了7行代碼


#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX      256

long total;

int countLince(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 main()
{
        char path = ".";
       
        printf("計算中...\n");
       
        findAllCodes(path);
        findALLDirs(path);
       
        printf("目前你總共寫了 %1d 行代碼!\n\n", total);
        system("pause");
       
        return 0;
}

ZTQ 发表于 2018-8-9 17:39:34

0: 计算机智能识别0和1
1:机械语言
2:编译
3:不能

胖胖浩 发表于 2018-8-9 19:19:02

加油

白茶巧克力 发表于 2018-8-9 21:30:45

有点难受 错了不少

Your_WQ 发表于 2018-8-9 22:53:16

来对对答案
页: 147 148 149 150 151 152 153 154 155 156 [157] 158 159 160 161 162 163 164 165 166
查看完整版本: S1E2:第一个程序 | 课后测试题及答案