小编yul*_*ian的帖子

数组未初始化.每个元素都包含垃圾,但不是必需值

  1. 第一个问题:0个错误,0个警告.当然代码是正确的.告诉我有什么问题?(这是程序的一部分.)我无法理解什么是错的.至少它会显示出来array[3][3] = {{1,1,1},{1,1,1},{1,1,1}}

  2. 第二个问题:但是我没有看到"零",而是看到了清晰的字段.(我什么都看不见)但是如果有的话{{1,1,1},{1,1,1},{1,1,1}},我会看到'1'...告诉我为什么?

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#define L 3            /* Including the [0]-element */
//#define C 3            /* Including the [0]-element */
#define RANGE 100      /* Set up the range of random values */

int fill_in(int *, int, int); /* Prototype of function */

int main()
{
   int L = 3, C = 3;

   int array[L][C];  // L - Line, C - Column
   int i, j;        // Global variables

   int * aPtr;
   aPtr …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
160
查看次数

应用程序在查找数组中的元素时崩溃

输入文件是in.wav.我必须读取块(成功)并读取样本以规范化音频文件...

问题是,它试图FING的崩溃maxmin.wav文件的采样值.它只会找到数组中的最小值和最大值,但它会崩溃 ...

请告诉我有什么问题.我认为没有理由这种行为.

这是代码:

#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#define hdr_SIZE 64

typedef struct FMT
{
    char        SubChunk1ID[4];
    int         SubChunk1Size;
    short int   AudioFormat;
    short int   NumChannels;
    int         SampleRate;
    int         ByteRate;
    short int   BlockAlign;
    short int   BitsPerSample;

} fmt;

typedef struct DATA
{
    char        Subchunk2ID[4];
    int         Subchunk2Size;
    int         Data[441000]; 
} data;

typedef struct HEADER
{
    char        ChunkID[4];
    int         ChunkSize;
    char        Format[4];
    fmt         S1;
    data        S2;
} header;



int main()
{
    FILE *input …
Run Code Online (Sandbox Code Playgroud)

c malloc pointers binaryfiles

0
推荐指数
1
解决办法
89
查看次数

为什么第二次使用 fread() 不是从头而是从第一次 fread() 读取的结尾读取文件?

我想hdrin.wav文件中的数据填充(struct) 变量,我想将文件的前 64 个字节复制in.wav到另一个文件 ( out.wav)。

但!fread()第二次使用时,in.wavfread()第一次使用结束的地方开始复制。为什么?

#include <stdio.h>
#include <stdlib.h>

typedef struct FMT
{
    char        SubChunk1ID[4];
    int         SubChunk1Size;
    short int   AudioFormat;
    short int   NumChannels;
    int         SampleRate;
    int         ByteRate;
    short int   BlockAlign;
    short int   BitsPerSample;
} fmt;

typedef struct DATA
{
    char        Subchunk2ID[4];
    int         Subchunk2Size;
    int         Data[441000]; // 10 secs of garbage. he-he)
} data;

typedef struct HEADER
{
    char        ChunkID[4];
    int         ChunkSize;
    char        Format[4];
    fmt         S1; …
Run Code Online (Sandbox Code Playgroud)

c file binary-data fread

-1
推荐指数
1
解决办法
4583
查看次数

在输出中看不到完整的单词

我想让这个程序打印字符串,但我看不到输出中的完整单词(在控制台中).将按此顺序排列:artictle(例如:"the","a","one","some","any"),名词,介词,文章,名词.

如果我在不使用函数的情况下打印字符串,它就能正常工作.但如果我使用我的功能,输出是不正确的.

我已经考虑了很长时间了,但我仍然不明白这种行为的原因.你能告诉我这个程序有什么问题吗?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int printSentence(int number, const char *article, const char *noun, const char *verb, const char *preposition);

int main(){

    int number;

    const char *article[5] = {"the", "a", "one", "some", "any"};
    const char *noun[5] = {"boy", "girl", "dog", "town", "car"};
    const char *verb[5] = {"drove", "jumped", "ran", "walked", "skipped"};
    const char *preposition[5] = {"to", "from", "over", "on", "under"};

    srand((unsigned)time(NULL));

    /* …
Run Code Online (Sandbox Code Playgroud)

c string pointers

-1
推荐指数
1
解决办法
113
查看次数

有谁可以请帮我这个程序编码?

我有一个程序要做我的作业.该计划很简单.它要求反转用户输入的数字,然后使用while循环打印它.当用户输入以零开头的数字时出现问题.

例如:

Enter the number: 0089
The reversed number is : 9800
Run Code Online (Sandbox Code Playgroud)

这就是输出的方式.相反,我得到"98"作为答案.

并提前感谢.

c reverse

-1
推荐指数
1
解决办法
195
查看次数

为什么我的代码会给出编译时错误?

我试图得到这个问题,但无法理解为什么它给出编译时错误我的代码是:

#include<stdio.h>
static struct student
{
    int a;
    int b;
    int c;
    int d;
}s1={6,7,8,9},s2={4,3,2,1},s3;
void main()
{
    s3=s1+s2;
    clrscr();
    printf("%d %d %d %d",s3.a,s3.b,s3.c,s3.d);
    getch();
}
Run Code Online (Sandbox Code Playgroud)

c compiler-errors

-1
推荐指数
2
解决办法
530
查看次数

为什么这个程序不适用于大于25个字符的输入?

这个程序适用于输入: "problem"

但停下来: "this is the problem,this is the problem,this is the problem"

为什么?

#include <stdio.h>

int main()
{
    char *p;
    gets(p);
    puts(p);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

有没有内存保护问题?

c pointers

-2
推荐指数
1
解决办法
119
查看次数