passing arg 1 of `show_costs' makes pointer with integer without cast

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 6
Reputation: Gerritt is an unknown quantity at this point 
Solved Threads: 0
Gerritt Gerritt is offline Offline
Newbie Poster

passing arg 1 of `show_costs' makes pointer with integer without cast

 
0
  #1
Mar 8th, 2008
My online class just started into arrays, and I am getting this nasty error "passing arg 1 of `show_costs' makes pointer with integer without cast".

I have no idea what the problem is. If anyone would be so kinda, please help.

BTW: sorry, I have a habit of naming my variable an assortment of oddies.


  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. #define COMPANY "Sierra Sporting Goods"
  6. #define mnum 1 /*Defining constants*/
  7. #define maxnum 9999
  8. #define mtype 1
  9. #define maxtype 5
  10. #define minquan 1
  11. #define maxquan 50
  12. #define mincost 5.00
  13. #define maxcost 900.00
  14. #define minprice 6.00
  15. #define maxprice 100.00
  16. #define sports 5
  17.  
  18. int menu(void);
  19. void add(void);
  20. double getreal(char word[], double min, double max);
  21. int getint(char stuff[], int min, int max);
  22. double total(int quan, double cos);
  23. double show(int num, int quan, double cost, double price);
  24. int quit(void);
  25. void error(double min, double max);
  26. void clearer(void);
  27. double init_costs(int n[], int c);
  28. double show_costs(int n[], double c);

AREA WITH THE ERROR:
  1. /*===============================================================*/
  2. void add()
  3. {
  4. int vala, valb, valc, log, bog=5;
  5. char alakazam;
  6. double vald, valf;
  7. clearer();
  8. do
  9. {
  10. init_costs(0, bog);
  11. vala = getint("Product Number", mnum, maxnum);
  12. valb = getint("Product Type", mtype, maxtype);
  13. valc = getint("Quantity", minquan, maxquan);
  14. for(log = 0; log < bog; log++) show_costs(log, vald);
  15. {
  16. vald = getreal("Cost", mincost, maxcost);
  17. }
  18. valf = getreal("Price", minprice, maxprice);
  19. show(vala, valc, vald, valf);
  20. printf("Again? (Y/N)");
  21. scanf("%c%*c", &alakazam);
  22. }
  23.  
  24. while(alakazam == 'Y' || alakazam == 'y');
  25. return;
  26. }
  27. /*======================================================*/
  28. /*====================================================================*/
  29. double show_costs(int n[], double c)
  30. {
  31. int scrub;
  32. if(n[] < 5)
  33. {
  34. n[scrub] == c;
  35. scrub++;
  36. }
  37. else
  38. {
  39. printf("Type-------------------------Cost");
  40. printf("1:---------------------------%lf", n[0];
  41. printf("2:---------------------------%lf", n[1];
  42. printf("3:---------------------------%lf", n[2];
  43. printf("4:---------------------------%lf", n[3];
  44. printf("5:---------------------------%lf", n[4];
  45. }
  46. return 0;
  47. }
  48.  
  49.  
  50. /*===========================================*/
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,048
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 179
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: passing arg 1 of `show_costs' makes pointer with integer without cast

 
0
  #2
Mar 9th, 2008
double show_costs(int n[], double c); first parameter is an array of integers

show_costs(log, vald); log is not an array of integers.

if(n[] < 5) incorrect syntax, there must be a subscript inside the []
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 980
Reputation: mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice 
Solved Threads: 210
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: passing arg 1 of `show_costs' makes pointer with integer without cast

 
0
  #3
Mar 9th, 2008
In your show_costs() function ...
int scrub;
if(n[some_valid_subscript_here] < 5)
{
    // what is the value of scrub here?
    //  and where does it come from??
    n[scrub] == c;  
    scrub++;
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum


Views: 1009 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC