我已经被赋予了一个任务,通过使用宏来将小写字符转换为大写.问题是我从未被引入宏.我只知道它的名字#define名称大小..请任何人都可以指导我这个问题
我是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不是吗?
谢谢
程序在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) 我刚刚遇到了这行代码,其中一个方法被实例化而没有使用+或 - .你能解释一下代码吗:
void *ABCD(NSString *xyz)
Run Code Online (Sandbox Code Playgroud) 所以我正在学习使用编译器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中的迷你扑克游戏创建一副牌.但我不明白西装和面孔是如何确定的.为什么这些阵列有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) 输入第一个输入后,程序关闭
#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) 当我明确说明字符串的值,然后将其与自身进行比较时,系统返回FALSE.这是否与系统添加的额外'\ 0'字符有关?我应该如何优化我的代码使其成为正确的?
char name[5] = "hello";
if(name == "hello")
{
...
}
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,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?
我查了一些过去的问题,但我没有得到它.感谢您的见解.