小编Sag*_*der的帖子

语法错误:缺少';' 在'类型'IN C之前

我试图完成我的代码.之后为数组分配内存.我得到的错误很少,因为他们我无法编译代码.我想得到你的帮助,完成程序谢谢!

1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(27): error C2143: syntax error : missing ';' before 'type'
1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(28): error C2065: 'text2' : undeclared identifier
1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(28): warning C4047: '=' : 'int' differs in levels of indirection from 'char **'
1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(29): error C2065: 'text2' : undeclared identifier
1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(36): error C2065: 'text2' : undeclared identifier
1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(36): error C2109: subscript requires array or pointer type
1>c:\users\roni\documents\visual studio 2010\projects\lb11_12\lb11_12\lb_11_12_02.c(38): error C2143: syntax error : missing ';' before 'type'
1>c:\users\roni\documents\visual …
Run Code Online (Sandbox Code Playgroud)

c visual-studio-2010 visual-studio

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

数组 - 按C中的模数排序

嘿伙计们,我正在尝试完成我的代码,但不是获取值,而是获取值的地址.这是为什么?
算法是否构建正确?我需要安排用户收到的数组排序.所有除以m等分的余数的数字0将出现在数组的开头,所有与除法的其余部分m相等的数字1将被跟随,其余的两个数字将出现在后面,依此类推.将持续其余数字的分布m等于m-1.

这是我的输出:

输出我的代码

这是我的代码:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void SortByModulo(int *arr,int m,int length);
void main()
{   int length,m,i;
    int *arr;
    printf("Please inseret array length:\n");
    scanf("%d" ,&length);
    arr=(int *)malloc(length*sizeof(int));
    if(!arr) // Terms - if there is not enough memory,print error msg and exit the program.
        {
            printf("alloc failed\n");
            return ;
        }
    for(i=0; i<length; i++)
        arr[i]=(int)malloc(length*sizeof(int)); // Allocate memory for each row
    printf("Please inseret %d elemetns :\n",length);
    for …
Run Code Online (Sandbox Code Playgroud)

c arrays sorting pointers

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