1. ## Array function help!

Edit:

I figured out my problem, it was that I am stupid. -_-

2. Read the number as a string directly - much easier.

3. Originally Posted by GReaper
Read the number as a string directly - much easier.
It's probably homework, I'd venture that he is required to do it this way.

Quzah.

4. Originally Posted by quzah
It's probably homework, I'd venture that he is required to do it this way.
Oh, my bad. Then, you know what to do:
Code:
`++a[digit];`
EDIT: ... Don't do that! A public conversation isn't deleted, and neither should you erase your post. We want others to learn from it!

5. Originally Posted by SirSig
Edit:

I figured out my problem, it was that I am stupid. -_-

Please don't delete your posts; it deprives everyone else of the chance to learn from it.

6. Originally Posted by SirSig
Edit:

I figured out my problem, it was that I am stupid. -_-

Ahhh, sorry I did not know the proper etiquette. I realized my problem as soon as I posted it so I did not want to take up any body's time.

My code was:

Code:
```/*-------------
Include Section
--------------*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#define SIZE 10

/*------------------Main Functions------------------
Purpose: Prompts user to input integer
Returns: Signal to the OS
--------------------------------------------------*/

void sep_digits(long long int num);
void print_digits(int a[], int size);

int main(void) {

long long int input;

printf("Enter a positive integer or 0 (zero) to end: ");
scanf("%lld", &input);

while (input != 0) {
if (input < 0) {
printf("\nWrong input\n");
}
else {
sep_digits(input);
}
printf("\nEnter a positive integer or 0 (zero) to end: ");
scanf("%lld", &input);
}
printf("\n*** Program Terminated ***\n");
return(EXIT_SUCCESS);
}

/*------------------Seperate Digits Functions------------------
Purpose: Seperates and counts the numbers in the user's input.
Returns: Seperated and counted value.
--------------------------------------------------*/

void sep_digits(long long int num) {

int a[SIZE] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int digit, i;

while (num > 0) { // num has the value of user input
digit = num % 10;

a[digit] = a[digit] + 1;

num = num / 10;
}
print_digits(a, SIZE);
}

/*------------------Print Digits Functions------------------
Purpose: Prints output.
Returns: Prints output of the sep_digit function to the user in a formatted orientation.
--------------------------------------------------*/

void print_digits(int a[], int size) {

int i;

printf("\n\n");
printf("Digits:         0  1  2  3  4  5  6  7  8  9\n");
printf("Occurrences:  ");
for (i = 0; i < 10; i++) {
printf("  %d",a[i]);
}
printf("\n");
}```
except for at this while loop:

Code:
```while (num > 0) { // num has the value of user input
digit = num % 10;

a[digit] = a[digit] + 1;

num = num / 10;
}```
I had improperly put the a[digit] increment in a way so that it did not actually increment a[digit] this causing no change.