C:\Userserror: too few arguments to function ‘void alpha(std::string*, student)’|

The following error:

C:\Users\main.cpp|25|error: too few arguments to function ‘void alpha(std::string*, student)’|

Is linked to this code:

void alpha(string*,student pArray);

I have looked through many forums and I have found nothing that can help.
Can someone explain this to me, or at least head me in the direction to some information that can?

I appreciate your help!
Post how you call it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "address.h"
#include "student.h"
#include "date.h"
#include "record.h"
#include "name.h"

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

#define pArray
#define students
#define Request

using namespace :: std;



enum {sNUMBER=50};

//Function Prototypes
void tPrint(string*,student pArray);
void sPrint(string*,student pArray);
void alpha(string*,student pArray);
int generate();
//Function Definitions
void tPrint(string*,student pArray)
{
    if (alpha != 0)
    {
        alpha(pArray);
    }//end if
    int i;
    for (i=0; i<sNUMBER;i++)
    {
        pArray->tPrint();
        pArray+=1;
    }//end for
};//end tPrint
void sPrint(string*,student pArray)
{
    if (alpha != 0)
    {
        alpha(pArray);
    }//ennd if
    int i;
    for (i=0; i<sNUMBER;i++)
    {
        pArray->sPrint();
        pArray+=1;
    }//end for
};//end sPrint
void alpha(string*,student pArray)
{
    int i;//counter
    int j;//counter
    for (i=0;i<sNUMBER-1;i++)
    {
        for (j=0;j<sNUMBER-1-i;j++)
        {
            //combine first and last names into full names
            if (strcmp((pArray->GetsName().GetfName())+=" " +=(pArray->GetsName().GetlName()),((pArray+1)->GetsName().GetfName())+=" "+=((pArray+1)->GetsName().GetlName()))>0)
            {
                swap(pArray[j],pArray[j+1]);
            }
        }//end for
    }//end for
};//end alpha

int generate ()
{
    srand(sNUMBER);
    ofstream data;
    data.open ("data.txt");
    if (data.is_open())
    {
        int i; // counter
        int j; // counter
        //Name info
        string new fName[sNUMBER];
        string new lName[sNUMBER];
        //Address info
        string new add1[sNUMBER];
        string new add2[sNUMBER];

        //variables to generate names
        string new fName1[5] = {"Alfred","Robert","Ryan","Hank","Richard"};
        string new fName2[5] = {"Hannah","Lacie","Crystal","Kayce","Susan"};
        string new lName1[5] = {"Smith","Jones","Allison","Johnson","Moore"};
        string new lName2[5] = {"Howard","Williams","Pinkston","Cooley","Vernon"};
        string new fNames[2] = {fName1,fName2};
        string new lNames[2] = {lName1,lName2};

        // variables to generate addresses
        string new adds1[5] = {"159 faternity st.","399 Dorm Blvd.","222 faternity st.", "777 Dorm Blvd", "82 Canal street"};
        string new adds2[10] = {"Apartment A", "Apartment B", "Apartment C", "Apartment D", "Apartment E","Apartment F", "Apartment G", "Apartment H", "Apartment I"};

        for (i=0;i<sNUMBER;i++)
        {
            for (j=0; j<5; j++)
            {
                strCopy(fName[i],fNames[i>25][j]);
                strCopy(lName[i],lNames[i>25][j + floor(i/5)-(i>25)*(floor(i/5)-6)- 4*((j+i/5)>5)]);

            }
        }





        for (i=0;i<sNUMBER;i++)
        {
            for (j=0; j<10; j++)
            {
                strCopy(add1[i],adds1[j]);
                strCopy(add2[i],adds2[j + floor(i/10)-(i>25)*(floor(i/10)-11)- 4*((j+i/10)>10)]);

            }
        }


        //deallocate unneeded variables
        delete [] fName1;
        delete [] fName2;
        delete [] lName1;
        delete [] lName2;
        delete [] fNames;
        delete [] lNames;

        for (i=0; i<sNUMBER;i++)
        {
            // name info
            Data << fName[i] << "\n"; // first name
            Data << lName[i] << "\n"; // last name
            // address info
            Data << add1[i] <" \n"; // add 1
            Data << add2[i] <" \n"; // add 2
            Data << "Indianapolis  \n"; // city
            Data << "IN  \n"; // state
            Data << "46168 \n"; // zip
            // birthdate
            Data << rand()%28 + 1  << " \n"; //day

            Data << rand()%12 + 1 << " \n";//month
            Data << 2011 -(rand()%49 + 12)<< "\n";//year
            //graddate
            Data << rand()%28 + 1 << " \n";//day

            Data << rand()%12 + 1 << " \n"; // month
            Data << 2011 + (rand()%6+2)<< " \n"; // year
            //performance info
            Data << (rand()%16)/(float rand()%4)<<" \n"; //gpa
            Data << (rand()%300)<< " \n"; //credits

        }

        //Deallocate rest of memory
        delete [] fName;
        delete [] lName;
        delete [] add1;
        delete [] add2;


        data.close();
    }
    else
    {
        cout << "Your file did not open. Sorry \n";
    }
    return 0;
}//end generate



The error above applies to line 25
On lines 30, 32, 43, and 45, you're not calling the function correctly...
Last edited on
So I should be calling student rather than alpha. Am I correct?
I have looked through these sets of documentation, but they don't really make sense to me in my case.

http://www.cplusplus.com/doc/tutorial/functions/
http://www.cplusplus.com/doc/tutorial/functions2/
Okay, I did notice that I only had one = in these instances instead of ==. Yet, the errors still exist.
I don't know what function you are supposed to call...but I do know that the error is because you have malformed function calls for the alpha function. On lines 30 and 43, you type "alpha" and then nothing else...alpha is a function, not a variable, so you have to include a parameter list with it! And on lines 32 and 45 you skip the first parameter (a string pointer). What's that for, anyway? Your functions all start with an unnamed and unused string pointer variable, so why do you have that? I think you want to remove the code string*, from your function declarations and definitions...this will stop the errors on lines 32 and 45.
Last edited on
LB,

Thank you for providing some kind of guidance. Obviously I am new to the C++ world and any information that I have tried to pull from the internet is all over God's green earth. Thus, I don't feel comfortable using some of the examples I have found as a guidance tool.

The purpose of this program is that it is a student record storage system. The code in question is the main.cpp. This system includes 5 other .cpp files as well as 5 header files. My ultimate goal is to store the information using arrays on a heap. I also need to pull this information from an external data.txt file.

If you come up with any additional information please let me know. I would even be excited to see any documentation that might lead me down the right path.

Thank you again!
Topic archived. No new replies allowed.