Thread: Can someone explain, why the programm is throwing 2 warning when compiling?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2022
    Posts
    4

    Can someone explain, why the programm is throwing 2 warning when compiling?

    Hey, i am completely new to C programming, learning it for my Uni right now, my C exercise group and me have absolutely no clue, why those warnings are thrown, when compiling the code. Also i dont really get the * and & and what exactly they do in the case. All i know is, that &variable stores the address from the RAM of the variable and that * creates a pointer (what ever that means?) or can somehow read what value at a &variable is...i am confused...here is the code:

    Code:
    #include <stdio.h>
    void f(int *);
    void f(int *ptr)
    {
      int ar[] = { 1, 2, 3, 4 };
      *ptr = &ar;
    }
    
    int main()
    {
      int *arr;
      f(&arr);
      for (int i = 0; i < 4; i++) {
        int d = arr[i];
        printf("The %d-th element is %d.\n", i, d);
      }
      return 0;                     //return Code 0 for all good
    
    }
    Last edited by Salem; 11-04-2022 at 01:21 PM. Reason: Removed crayola

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 03-23-2013, 01:44 PM
  2. Get rid of compiling warning?
    By tmac619619 in forum C Programming
    Replies: 7
    Last Post: 10-13-2012, 03:37 PM
  3. Compiling Warning
    By Micki-Zee in forum C Programming
    Replies: 3
    Last Post: 06-29-2011, 09:40 AM
  4. Replies: 3
    Last Post: 03-01-2011, 07:00 PM
  5. Compiling warning..
    By Jez_Master in forum C++ Programming
    Replies: 2
    Last Post: 05-01-2002, 10:45 PM

Tags for this Thread