标签云

微信群

扫码加入我们

WeChat QR Code

I'm a beginner in C. I am having trouble with this array function. When I call the function, it will ask for the input of a pair of numbers (key, value) each time, and store it in a one-dimensional array. I will have to store the pair one-by-one by constantly calling the function. Below is what I have currently and I think I'm not storing it correctlyedit: sorry, noticed how bad my question was. I think I'm not storing it correctly as when I call upon other functions such as sum (summing the values), I get 0 or the wrong answer. Also, updated the code to include main function for further details. The size of the array is limited to 100. #define SIZE 100int main(void) {int arr[SIZE] = {0};void insert_table(int arr[], int length) {int i;for (i=0; i<SIZE; i=i+2){scanf("%d", &arr[i]);scanf("%d", &arr[i+1];break;}


You think you're not doing it correctly? Why? What are your concerns? Does your code work? If not, how? Also provide a minimal reproducible example

2019年06月26日57分13秒

Perhaps you need to do some rubber duck debugging of your function?

2019年06月26日57分13秒

Why don't you use length?

2019年06月26日57分13秒

The current code wont even compile at all. and it is far from complete.

2019年06月26日57分13秒

Please read the help pages, take the SO tour, read about how to ask good questions, as well as this question checklist. Lastly learn how to create a minimal reproducible example.

2019年06月26日57分13秒