我将如何摆脱这些不允许我编译的语法错误?
这对于正在做的事情具有正确的结构,但是这些错误使我无法对其进行测试。
我非常接近测试这个。我做了 int array 和 int pointer 来修复其中一些错误,但是在下一个错误的行中执行它们并不能修复它们。
这都是相同类型的错误。
Pointers.c: In function ‘ArrayInitialize’:
Pointers.c:19: error: expected ‘;’ before ‘)’ token
Pointers.c:23: error: expected ‘;’ before ‘)’ token
Pointers.c:25: warning: assignment makes integer from pointer without a cast
Pointers.c: At top level:
Pointers.c:32: error: expected ‘)’ before ‘array’
Pointers.c:44: error: expected ‘)’ before ‘array’
Pointers.c:56: error: expected ‘)’ before ‘array’
Pointers.c:78: error: expected ‘)’ before ‘pointer’
#include <stdio.h>
#include <stdlib.h>
#define SIZE_OF_ARRAY 5
//=============================================================================
int *IntegerPtr;
int ArrayInt[SIZE_OF_ARRAY];
int *ArrayPtr[SIZE_OF_ARRAY];
//-----------------------------------------------------------------------------
void ArrayInitialize(int *array,int *pointer){
int i;
srand(getpid());
for (i =0, i < SIZE_OF_ARRAY; i++;){
array[i] = (int)rand();
for (i =0, i < SIZE_OF_ARRAY; i++;){
pointer[i] = &array[i];
}
}
}
//-----------------------------------------------------------------------------
void ArrayPrint(ArrayInt array){
int i;
for (i =0, int < SIZE_OF_ARRAY; i++;){
printf("%d : %10d \n",i,array[i]);
}
printf("\n");
}
//-----------------------------------------------------------------------------
void ArrayPointerPrint(ArrayInt array){
int i;
for (i =0, i < SIZE_OF_ARRAY; i++){
printf("%d : %10d \n",i,pointer[i]);
}
printf("\n");
}
//-----------------------------------------------------------------------------
void ArrayBubbleSort(ArrayInt array){
int i;
int j;
int temp;
for( i = (SIZE_OF_ARRAY - 1); i >= 0; i-- )
{
for( j = 1; j <= i; j++ )
{
if( *(array+(j-1)) > *(array+j))
{
temp = *array+(j-1));
*array+(j-1)) = array+(j));
*array+(j) = temp;
}
}
}
}
//-----------------------------------------------------------------------------
void PointerBubbleSort(ArrayPtr pointer){
int i;
int j;
int temp;
for( i = (SIZE_OF_ARRAY - 1); i >= 0; i-- )
{
for( j = 1; j <= i; j++ )
{
if( *(pointer+(j-1)) > *(pointer+j))
{
temp = *pointer+(j-1));
*pointer+(j-1)) = pointer+(j));
*pointer+(j) = temp;
}
}
}
}
//-----------------------------------------------------------------------------
int main(void) {
int array[SIZE_OF_ARRAY];
int pointer[SIZE_OF_ARRAY];
ArrayInitialize(array,pointer);
ArrayPrint(array);
PointerBubbleSort(pointer);
ArrayPointerPrint(pointer);
ArrayBubbleSort(array);
ArrayPrint(array);
ArrayPointerPrint(pointer);
return(EXIT_SUCCESS);
}