473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I am writing a program passing functions to arrays

i am passing a float and a integer into the function

error: function does not take 1 arguments

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define AgentSize 5
  6. void DisplayWelcome(void);
  7. void Type(int);
  8. void category();
  9. void Budget(float);
  10.  
  11. int main()
  12. {
  13. char Agentfinitial[AgentSize], Agentlinitial[AgentSize];
  14. int i=0, AType[AgentSize], MaxAgent[AgentSize]={0};
  15. int AgentType[AgentSize]={0};
  16. float ibudget[AgentSize], excess[AgentSize]={0}, totmissionbudget[AgentSize]={0};
  17. int Agent[AgentSize]={0}, Agentctr[AgentSize]={0}; 
  18. char cat;
  19.  
  20.  
  21.  
  22. DisplayWelcome();
  23. for (i=0; i<AgentSize; i++)
  24. {
  25. printf("\nPlease enter first and last initial\n");
  26. scanf("%c%c", &Agentfinitial[AgentSize], &Agentlinitial[AgentSize]);getchar();
  27.  
  28. printf("\nPlease enter Agent Type\n");
  29. scanf("%d", &AType[AgentSize]);getchar();
  30. Type(AType[AgentSize]);
  31.  
  32. printf("\nYou are allowed an additional 5%% of your budget\n");
  33. printf("\nPlease enter budget\n");
  34. scanf("%f", &ibudget[AgentSize]); getchar();
  35. Budget(ibudget); <<AT THIS POINT


THIS IS THE FUNCTION:
Expand|Select|Wrap|Line Numbers
  1. void Budget(float ibudget[AgentSize],int AType[])
  2.  
  3. {
  4. float excess[AgentSize]={0}, totmissionbudget[AgentSize]={0};
  5.  
  6. if (AType[AgentSize]==1)
  7. {
  8.  
  9. excess[AgentSize] =  ibudget[AgentSize]* 0.05;
  10. totmissionbudget[AgentSize]= excess[AgentSize] + ibudget[AgentSize];
  11. printf("\nThe total mission budget is %f", totmissionbudget[AgentSize]);
  12.             }
  13. else  if(AType[AgentSize]==2)
  14. {
  15. printf("\n This agent is not allowed an excess\n");
  16. totmissionbudget[AgentSize] = ibudget[AgentSize] + totmissionbudget[AgentSize];
  17. printf("\nThe total mission budget is %f", totmissionbudget[AgentSize]);
  18. }
  19.  
  20.  else if (AType[AgentSize]==3)
  21. {
  22. printf("\nThis Agent will incur a 5%% penalty if overbudget\n");
  23. totmissionbudget[AgentSize] = ibudget[AgentSize]+totmissionbudget[AgentSize];
  24. printf("\nThe total mission budget %f", totmissionbudget[AgentSize]);
  25. }
  26.  
  27.  else 
  28. {
  29. Printf("\nYou need to enter a budget\n");
  30. }
  31.  
  32.  
  33.         }//end budget function
Nov 25 '10 #1
1 1395
donbock
2,426 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. void Budget(float);
  2. ...
  3. float ibudget[AgentSize];
  4. ...
  5. Budget(ibudget);
  6. ...
  7. void Budget(float ibudget[AgentSize],int AType[]) {
  8.    ...
  9.    }
Your prototype says Budget has a single float argument; you pass an array of floats when you call Budget; and you define Budget with two arguments: an array of float and an array of int. The compiler doesn't like inconsistencies like these.

By the way, the compiler doesn't enforce any particular size for array arguments so specifying the size of the ibudget array in the declaration doesn't accomplish anything. Refer to Arrays Revealed for advice on how to pass arrays to functions.
Nov 26 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: dave.harper | last post by:
I'm relatively new to C++, but have a question regarding functions and arrays. I'm passing a relatively large array to a function several thousand times during the course of a loop, and it seems...
10
by: WindAndWaves | last post by:
Hi Folks I know that this is possible: Function tt(x as string, nv()) where NV is an array. What I am wondering is if NV can be a multidimensional array.
3
by: Sascha Herpers | last post by:
Hi, I wrote a c dll with a type library to use it in vb. No problem, everything works fine. Now I needed to pass an array of type double to the dll. I defined the function in the type...
3
by: Thomas Christmann | last post by:
Hi! Sorry for the weird topic, I don't know how to describe it better... I have a little problem here I can't wrap my mind around. If I do: ------------------------------------- #define DWORD...
1
by: nickolais909 | last post by:
Hello, I have an old C++ DLL that I am wishing to use in a VB.NET program. Previously I had a VB6 program that would pass a Type to a DLL function. For example, I would pass a variable of this...
1
by: sparkid | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
4
by: canteyn | last post by:
Ok here is my problem. I am coding a program that uses 3 different functions, and the end result is that the program reads in (x,y) points from a file, and then outputs those points to another file,...
16
by: Nkhosinathie | last post by:
hi, i'm writing a program that is using 4 arrays of pointers to char,called article,noun,verb and preposition.the program should create a sentence by selecting a word at random from each array in the...
8
by: S. | last post by:
Hi all, Can someone please help me with this? I have the following struct: typedef struct { char *name; int age; } Student;
6
by: nigelmercier | last post by:
I'm still not comfortable with passing character arrays, and I think this is the problem with this code: char * formatHours(int decimin) { // convert integer deci-mins (6 seconds) to string:...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.