小编Gri*_*han的帖子

为什么++ i ++在C中给出"L值必需错误"?

在下面的代码中:

main()
{
  int i = 5;
  printf("%d", ++i++);
}
Run Code Online (Sandbox Code Playgroud)

本程序给出错误"L-Value required".

有人可以告诉我:为什么编译错误?

c

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

解释为什么在相同的代码中的差异

我的代码是:

 code(){
    int x=7;
    x=x++;
    output x;   //prints 8 in C, prints 7 in Java
 }
Run Code Online (Sandbox Code Playgroud)

球员上面的代码:打印8C,和7Java!!

为什么会这样?请解释.

c java

0
推荐指数
3
解决办法
183
查看次数

替换字符串中的字符

我试图替换'G','R'但我得到未处理的异常.

int main()
{
    char *pszStr1 = "EFGH";

    (++pszStr1)[1] = 'R';

    printf("%s", pszStr1);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c string

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

程序未显示预期输出

以下C程序的预期输出是打印数组中的元素.但是当实际运行时,它不会这样做.

  #include<stdio.h>

  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};

  int main()
  {
      int d;

      for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
          printf("%d\n",array[d+1]);//printing the array

      return 0;
  }//looks simple but no result
Run Code Online (Sandbox Code Playgroud)

出了什么问题?为什么我没有得到任何输出?

c arrays

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

不知道为什么我得到一个TypeError

num_trades = int(input("Number of trades for today? "))
for i in range(1, num_trades + 1):
    print()
    action = input("Trade number", i, "(buy/sell)? ")
    num_shares = int(input("Number of shares to buy? "))
Run Code Online (Sandbox Code Playgroud)

我正在TypeError上线,"action = input("Trade number", i, "(buy/sell)? ")"

此错误消息显示" TypeError: input expected at most 1 arguments, got 3"

不知道它意味着什么,不知道如何纠正.救命

谢谢

python typeerror

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

在C++中截断

今天我试着编写一个程序来总结用户输入的整数.例如,如果用户输入683它将返回6 + 8 + 3 = 17.

但我在代码中遇到了一些奇怪的问题

代码 :

#包括

using namespace std;
int computeSum(int num);
int computeInteger(int num, int position);

int main()
{
    int num;
    int sum;
    int total;
    cin >> num;

    total = computeSum(num);

    cout << total;
    return 0;
}

int computeSum(int num) 
{
    int position = 10;
    int temp = num;
    double total = 0;
    bool finish = false;

    while(!finish)
    {
        total = total + computeInteger(num, position);

        if(num/ position == 0)
            break;
        position *= …
Run Code Online (Sandbox Code Playgroud)

c++ floating-point truncation

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

你如何在python中添加一系列数字

我有一个奇数列表但我仍然需要添加它们:

for n in range(100, 200):
   if n % 2 == 1:
       print sum([n])
Run Code Online (Sandbox Code Playgroud)

python

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

c分割核心转储?

我有一个功能来添加向量和存储结果,我无法解决为什么我得到分段核心转储.暂时不做C:/

void add(int *a, int *b, int *c, int n){
   int i;

   for(i = 0 ; i < n; n++)
   {
     c[i] = a[i] + b[i];
     i++;
   }

}

int main() {
 // vector_size = 100000
 // vector_a init with 100000 values
 // vector_b init with 100000 values

 int *result = malloc(vector_size * sizeof(int));
 add(vector_a,vector_b,result,vector_size);
}
Run Code Online (Sandbox Code Playgroud)

c arrays malloc

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

在LCD上显示十六进制值

我存储了数据text_buf[4] = {0x1d, 0x72, 0x2f, 0x32}.当我将它发送到LCD上显示时,它会显示一些垃圾.据我所知,LCD只显示字符串,如何显示存储的十六进制值text_buf?这有什么C的例子吗?请告诉我.

c

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

素数计划

我想用C语言编写一个程序来接受用户输入,我将无法理解循环的逻辑.

for ( c = 2 ; c <= n - 1 ; c++ )
Run Code Online (Sandbox Code Playgroud)

程序代码如下: -

#include<stdio.h>
#include<conio.h>

void main()
{
   int n, c;

   printf("Enter a number to check if it is prime\n");
   scanf("%d", &n);

   for ( c = 2 ; c <= n - 1 ; c++ )
   {
      if ( n % c == 0 )
      {
         printf("%d is not prime.\n", n);
         break;
      }
   }
   if ( c == n )
      printf("%d is prime.\n", n);

   getch();
} …
Run Code Online (Sandbox Code Playgroud)

c numbers

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

标签 统计

c ×7

arrays ×2

python ×2

c++ ×1

floating-point ×1

java ×1

malloc ×1

numbers ×1

string ×1

truncation ×1

typeerror ×1