我keepi讓我的代碼的一部分跳過了,它是當用戶選擇zerio,我去如果選擇0然後這樣做,但它只是完全跳過它程序傳遞if語句並需要指向對象類型的指針
if (select = 0)
{
for (i = 0; i < 20; ++i)
printf("%d", array[i]);
//// whenever I enter zero it skips over this if entirely
}
也,當我嘗試調用一個函數,並打印出來,我不斷收到,我必須有一個指針對象類型
if (select = 1)
{
square(array, 20);
for(j = 0; j < 20; ++j);
printf("%d", a[j]);
//the j reads that I need a pointer-to-object type
}
這是我的全部代碼。這是我玩弄試圖重新學習的東西
#include<stdio.h>
#include<conio.h>
void initialize(int a[], int size)
{
int i;
}
void square(int a[], int size)
{
int j;
for(j = 0; j < size; ++j)
a[j] = a[j] * a[j];
}
int main (void)
{
int array[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,19};
int i,j,k,l,m, select, a, size;
void initialize (int a[], int size);
void square (int a[], int size);
printf("Please select an option from the form \n\n 0 - initialize \n\n 1 - square \n\n 2 ");
scanf("%d", &select);
if (select = 0)
{
for (i = 0; i < 20; ++i)
printf("%d", array[i]);
//// whenever I enter zero it skips over this if entirely
}
if (select = 1)
{
square(array, 20);
for(j = 0; j < 20; ++j);
printf("%d", a[j]);
//the j reads that I need a pointer-to-object type
}
}
在'if',你使用''==而不是' ='表示平等。 – AntonH
我甚至無法正確縮進代碼以幫助您。請刪除空格。 – lrobb