相关疑难解决方法(0)

使用宏转换为大写

我已经被赋予了一个任务,通过使用宏来将小写字符转换为大写.问题是我从未被引入宏.我只知道它的名字#define名称大小..请任何人都可以指导我这个问题

c

0
推荐指数
2
解决办法
7562
查看次数

循环在C帮助!

我的朋友告诉我,存在一个特殊的循环,它不是'while'循环或'do while'循环.

有谁知道它的名称和使用它的正确语法?

c for-loop

0
推荐指数
6
解决办法
688
查看次数

预期'uint32_t'但参数类型为'uint32_t*'

我是C的新手,试图调用一个函数,但它给了我错误,我无法理解为什么

int set_price(&colour-> type.name);

它回报了我 expected ‘uint32_t’ but argument is of type ‘uint32_t *’. warning: passing argument ‘int set_price’ makes integer from pointer without a cast

指针在哪里

house_list*color = NULL;

和name在struct中定义

uint32_t名称;

原来的功能接受

int set_price(uint32_t name)
{
/ 在这里做点什么/
}

我做错了什么?如果在struct成员中,name被定义为uint32_t,并且我定义了一个指针颜色,我相信我需要在colour-> type之前使用&并且在name之前使用dot不是吗?

谢谢

c

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

程序在Linux上生成核心转储,但在Windows上运行正常

程序在Linux上生成核心转储,但在Windows上运行正常.知道为什么吗?

#include <stdio.h>

int main() {
    int i, n;
    int count[n];
    int total;
    int value;
    int d;

    printf("Enter the length of array: ");
    scanf("%d", &n);

    //printf ("total of array is %4d \n", n);

    for (i=0; i<=n-1 ; i++ ) {
        printf("Enter the number %d: ", i);
        scanf("%d", &count[i]);
        //  printf ("total of array is %4d \n", n);
    }

    //printf ("total of array is %4d \n", n);

    value = totalcalc( count, n);        
    printf ("total of array is %3d \n", value);

    scanf …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
2
解决办法
176
查看次数

这是什么类型的方法声明?

我刚刚遇到了这行代码,其中一个方法被实例化而没有使用+或 - .你能解释一下代码吗:

void *ABCD(NSString *xyz)
Run Code Online (Sandbox Code Playgroud)

methods objective-c ios

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

C编程中对字符串的困惑

所以我正在学习使用编译器Dev C++编程c.问题1:

#include <stdio.h> 
#include <conio.h> //for the getch() function
#include <string.h> 

int main(void) 
{ 
    char line[3]; 
    strcpy(line, "Hello world"); 
    printf("%s", line); 
    getch(); 
} 
Run Code Online (Sandbox Code Playgroud)

输出:Hello world

为什么当我声明我的字符串只能容纳3个字符时,它会显示所有"Hello world"?

问题2:

char line[3] = "Hello world"; 
printf("%s", line); 
Run Code Online (Sandbox Code Playgroud)

输出:Hel

为什么显示"Hel"?它不应该只显示"He",因为行[0] = H,行[1] = e和行[2] ='\ 0'?%s通过搜索'\ 0'来工作?

请帮我理解真正发生的事情.谢谢!

c printf c-strings string-literals array-initialization

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

C中的扑克牌游戏.请解释西装[4] [9],并面对[13] [6]?

所以我有一个示例代码,用于为的迷你扑克游戏创建一副牌.但我不明白西装和面孔是如何确定的.为什么这些阵列有2个维度?我知道[9]并且[6]是数组的列,但我不明白它们的目的.

char suits[4][9]= {"Hearts","Diamonds","Clubs","Spades"};   
char faces[13][6]= {"Ace","2","3","4","5","6","7","8","9", "10","Jack",
                "Queen","King"};
Run Code Online (Sandbox Code Playgroud)

c arrays poker

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

首次输入后运行C程序时出错

输入第一个输入后,程序关闭

#include<stdio.h>
int main(void)
{
    int biology,chemistry;
    printf("\nEnter marks for maths");
    scanf("%d",biology);
    printf("\nEnter marks for tech1");
    scanf("%d",chemistry);
    return(0);
}
Run Code Online (Sandbox Code Playgroud)

c

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

C字符串长度

当我明确说明字符串的值,然后将其与自身进行比较时,系统返回FALSE.这是否与系统添加的额外'\ 0'字符有关?我应该如何优化我的代码使其成为正确的?

char name[5] = "hello";

if(name == "hello")
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

c arrays string char

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

getchar()在C中将'10'读入'1'和'0'

我正在使功能像

输入包含:"1 2 3 4 5 6 7 8 9 10 \n"

功能输出:"{1,2,3,4,5,6,7,8,9,10} \n"

我想看看getchar()是如何工作的,所以我写了这样的函数:

    int c ;

    printf("{");

    while ((c = getchar()) != EOF) {
            printf("%c, ", c);
            getchar();

    }
    getchar();
    printf("}\n");
Run Code Online (Sandbox Code Playgroud)

当我把"1 2 3 4 5 6 7 8 9 10 \n"时,它就像:

{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 
 , }
Run Code Online (Sandbox Code Playgroud)

我觉得里面的缓冲区有问题.也许getchar()逐个字符地读出和输出,以便10分别被认为是1和0?

我查了一些过去的问题,但我没有得到它.感谢您的见解.

c

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