Thread: c program to debug

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    7

    c program to debug

    Code:
    #include<stdio.h>
    #include<conio.h>
    void disp(int *);
    void show(int *);
    void main()
    {
      int i;
      int marks[]={55,65,75,56,78,78,90};
      clrscr();
      for(i=0;i<=6;i++)
       disp(&marks[i]);
     getch();
    }
    void disp(int *n)
    {
     show(&n);
     //printf("\n%d",*n);
    }
    void show(int *m)
    {
     printf("\n%d",**m);
    }
    
    i have to print the contents of array but it is not working.
    please help me.
    and it is mandatory to use show() function

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    You do not need pointers and addresses to disply array contents...

    It is just silly to write a function that does nothing but call another function. Call show() function directly.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Inside disp(), call show() like this: show(n)
    Inside show(), use: printf("\n%d",*m) (single '*')

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 10-18-2009, 02:33 AM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Plz help me to debug my program
    By Bage in forum Linux Programming
    Replies: 1
    Last Post: 04-02-2004, 01:54 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

Tags for this Thread