这是我的代码,我仍然继续看错了,我是初学者,我想学习:
#include<stdio.h>
int main()
{
int a;
printf("Input: ");
scanf("%d", &a);
printf("\n%d", &a);
a+=2;
printf("\n%d", &a);
a+=4;
printf("\n%d", &a);
a+=2;
printf("\n%d", &a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
Input: 10
-1078169908
-1078169908
-1078169908
-1078169908
Run Code Online (Sandbox Code Playgroud) 如何获取recv()套接字通信recv()返回的错误号或错误字符串,返回-1读取大小,这意味着发生了一些错误.我想知道错误的具体原因.所以我怎么能得到它.
/*
/**hiiii**/
*/
Run Code Online (Sandbox Code Playgroud)
说我像这样嵌套评论,所以这有什么不对?在开始时我们有/*一个字符串在里面,然后最后我们在最后*/,所以这里的错误是什么?
我正在阅读Kernighan Ritchie并且有这个角色计数程序,所以我尝试了实施
#include <stdio.h>
#include <stdlib.h>
int main()
{
char c;
int i;
c = getchar();
while (c != EOF)
i= i + 1;
printf("%d",i);
}`
Run Code Online (Sandbox Code Playgroud)
当我编译并运行此代码时,在输入一些字符后,之后没有输出.没有打印数字,我无法弄清楚原因.代码看起来很好.我也试过使用scanf(),但同样的事情发生了.
下一个例子是计算输入中的行数,同样的问题也存在.
我有一个2维数组,当我第一次打印数组的数据时,日期打印正确,但另一次数组[last] [i]的数据从i = 0到last - 1.
显然是一个逻辑错误,但我不明白原因,因为我复制并粘贴了for语句.那么......¿C改变数据?
我使用gcc -std=c99但在此之前我尝试使用C++和cout语句.
#include <stdio.h>
int main(int argc, char *argv[])
{
unsigned int numero_jugaderes = 11;
unsigned int numero = numero_jugaderes - 1;
unsigned int p_a[numero];
float p_aya[numero][numero];
for (unsigned int i = 0; i <= numero; i++) {
p_a[i] = i;
}
for (unsigned int i = 0; i <= numero; i++) {
for (unsigned int j = 0; j <= numero; j++) {
p_aya[i][j] = (float) (p_a[i] …Run Code Online (Sandbox Code Playgroud) 我希望能够在c中打印出charcter的值,如下所示:
fprintf("%c", alphabet[val]);
Run Code Online (Sandbox Code Playgroud)
,其中字母表被初始化为
for(i = 0; i < 26; i++){
alphabet[i] = i + 65;
}
Run Code Online (Sandbox Code Playgroud)
但是,此行会出现以下错误:
encode.c: In function ‘main’:
encode.c:76:13: warning: passing argument 1 of ‘fprintf’ from incompatible pointer type [-Wincompatible-pointer-types]
fprintf("%c", alphabet[val]);
^
In file included from encode.c:1:0:
/usr/include/stdio.h:356:12: note: expected ‘FILE * restrict {aka struct _IO_FILE * restrict}’ but argument is of type ‘char *’
extern int fprintf (FILE *__restrict __stream,
^
encode.c:76:19: warning: passing argument 2 of ‘fprintf’ makes pointer from integer without a …Run Code Online (Sandbox Code Playgroud) 据我所知,以下代码可用于获取数组的长度(表示它包含多少项)(在本例中为整数数组):
int arrayOfInt[] = { 10, 20, 30, 40, 50 };
int lenght = sizeof(arrayOfInt) / sizeof(int);
Run Code Online (Sandbox Code Playgroud)
这给出"5"作为输出,这是正确的.但是,如果我在函数中使用相同的代码,则它不起作用.
int getLenght(int intArray[])
{
return sizeof(intArray) / sizeof(int);
}
lenght = getLenght(arrayOfInt);
Run Code Online (Sandbox Code Playgroud)
使用上面的函数,我得到"1"作为输出.哪个不对.为什么会这样?我做错了什么或不可能?
switch(at){
case (at>0 && at<5) :
printf("Average Time Taken (Hrs)\n%d.0",at);
printf("Your Salary is Rs.%d",pj*1500 + 5000);
break;
Run Code Online (Sandbox Code Playgroud)
其余的代码是相似的.我收到了这个错误case (at>0 && at<5) :
在我不小心使用的代码中
list* Head = malloc(sizeof(list*));
Run Code Online (Sandbox Code Playgroud)
而不是正确的
list* Head = malloc(sizeof(list));
Run Code Online (Sandbox Code Playgroud)
创建一个新的list类型节点,但以后工作得很好.
所以我的问题是为什么它能正常工作?
如果-8和7不为0,为什么输出为假?我知道它应该是&&但问题是"代码中是否存在问题?它是什么?为什么输出为假?" 请有人帮忙.
#include <stdio.h>
int main ()
{
if (-8 & 7)
{
printf("Always\n");
}
else
{
printf("False\n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)