473,805 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1421
donbock
2,426 Recognized Expert Top Contributor
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
1971
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 to get bogged down. Do the arrays previously passed to the function stay memory resident? If not, what's causing it and what can I do to correct it? Thanks, Dave
10
2736
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
3333
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 library like this: double VBEXPORT aigIGApproximation( double intervalCount,
3
2088
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 unsigned long #include <stdio.h> #include <malloc.h>
1
1713
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 Type in: Public Type ListInfo ' structure to hold information about the list file FileIndex As Integer filename(MAXNAME) As Byte FileNum As Integer
1
3566
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 run, However, i simply created this program in arrays and it runs good except i cant figure out how to compute the standard deviation. The coding is below. Any help will be appreciated. 1) The Program will prompt the user for six grades to be...
4
1986
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, and then calculates the area of the points(which form a polygon). I am able to compile the program just fine, but every time I try and run the program I just get a "segmentation fault". It may be in regards to my arrays, in fact I am almost sure...
16
5841
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 following order:article,noun,verb preposition,,article and noun.as each word is picked,it should be concatenated to the previous words in an array that is large enough to hold the entire sentence. the words should be separated by spaces.when the...
8
3509
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
2940
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: "XXhYYm" byte hrs, mins ; char time ; // global scratch variable txt4 is also char hrs = decimin / (60 * 10) ; // convert 1/10s of a minute into hours mins = decimin % (60 * 10) ; // remainder of same division is minutes ...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.