#Iterating from a Pointer to An array

7 messages · Page 1 of 1 (latest)

cerulean shadowBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

trail schooner
#

!debugger

cerulean shadowBOT
# trail schooner !debugger

@still roost
Have you tried stepping through your code line by line in a debugger?

If you don't know how to use a debugger or don't have one set up, we highly recommend taking the time to do so.
Debuggers are immensely helpful tools for figuring out where problems emerge in code and especially when you're first learning it can help you build intuition and understanding for reasoning through code.

Resources:

#

@still roost

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

still roost
#

!solved

cerulean shadowBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

solemn vale
#
#include <stdlib.h>
#include <stdio.h>

#define SIZE_MAX 100

void print_tab(size_t n, const int *arr) {
  for (size_t i = 0; i < n; ++i) {
    printf("%zu->%d\t",i+1 ,arr[i]);
  }
}

int main() {
  size_t n = 0;
  int x;
  int array[SIZE_MAX];
  while ( scanf("%d", &x) != EOF) {
    array[n] = x;
    ++n;
  }
  if (ferror(stdin)){
    return EXIT_FAILURE;
  }
  print_tab(n, array);
  return EXIT_SUCCESS;
}