473,408 Members | 2,888 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,408 software developers and data experts.

function definition problem

The following error appears for the code I'm writing:
error C2062: type 'int' unexpected
C:\Program Files\Microsoft Visual
Studio\MyProjects\Valid\Zenith124\Zenith.cpp(427) : error C2143:
syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual
Studio\MyProjects\Valid\Zenith124\Zenith.cpp(427) : error C2447:
missing function header (old-style formal list?)
Error executing cl.exe.

Zenith.obj - 3 error(s), 0 warning(s)

All errors are related to the function definition, all structures are
global declared and I tried decalring the variable check_digit with no
success.
Those that have responded in the past may already have seen this code
and it would be a pleasure to hear from you again.

struct sum {
int calculation[5];
int calc[6];
int weight_factor[4];
};

union records {
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
};
int check_mod(union records, int check_digit);// function prototype.


function defintion.
int check_mod(files, int check_digit)
{

check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));

for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] *
files.rec1.part_num[1];
check.calculation[2] = check.weight_factor[2] *
files.rec1.part_num[2];
check.calculation[3] = check.weight_factor[3] *
files.rec1.part_num[3];
check.calculation[4] = check.weight_factor[4] *
files.rec1.part_num[4];
check.calculation[5] = check.weight_factor[5] *
files.rec1.part_num[5];
check.calculation[6] = check.weight_factor[6] *
files.rec1.part_num[6];
};

result = (sizeof(result)/sizeof(check.calculation[0]));

while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};

remainder = result % mod;

check_digit = mod - remainder;

if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec.customer_code));
};

};
Jul 19 '05 #1
3 6977
"muser" <ch**********@hotmail.com> wrote...
The following error appears for the code I'm writing:
[...]
function defintion.
int check_mod(files, int check_digit)
What type does 'files' have?
{
[...]

Jul 19 '05 #2
muser wrote:
The following error appears for the code I'm writing:
error C2062: type 'int' unexpected
C:\Program Files\Microsoft Visual
Studio\MyProjects\Valid\Zenith124\Zenith.cpp(427) : error C2143:
syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual
Studio\MyProjects\Valid\Zenith124\Zenith.cpp(427) : error C2447:
missing function header (old-style formal list?)
Error executing cl.exe.

Zenith.obj - 3 error(s), 0 warning(s)

All errors are related to the function definition, all structures are
global declared and I tried decalring the variable check_digit with no
success.
Those that have responded in the past may already have seen this code
and it would be a pleasure to hear from you again.

struct sum {
int calculation[5];
int calc[6];
int weight_factor[4];
};

union records {
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
};
int check_mod(union records, int check_digit);// function prototype.


function defintion.
int check_mod(files, int check_digit)


Wouldn't that have to be like the following?

int check_mod(union records files, int check_digit)

--
"Codito ergo sum"
Roel Schroeven
Jul 19 '05 #3
"muser" <ch**********@hotmail.com> wrote in message
news:f9**************************@posting.google.c om...
The following error appears for the code I'm writing:
error C2062: type 'int' unexpected
C:\Program Files\Microsoft Visual
Studio\MyProjects\Valid\Zenith124\Zenith.cpp(427) : error C2143:
syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual
Studio\MyProjects\Valid\Zenith124\Zenith.cpp(427) : error C2447:
missing function header (old-style formal list?)
Error executing cl.exe.

Zenith.obj - 3 error(s), 0 warning(s)

All errors are related to the function definition, all structures are
global declared and I tried decalring the variable check_digit with no
success.
Those that have responded in the past may already have seen this code
and it would be a pleasure to hear from you again.

struct sum {
int calculation[5];
int calc[6];
int weight_factor[4];
};

union records {
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
};
int check_mod(union records, int check_digit);// function prototype.


function defintion.
int check_mod(files, int check_digit)


Your prototype does not match the definition. Did you mean:

int check_mod(union records, int check_digit)

?

Other than that, pretty much every line of your code seems flawed. Maybe
you want to look over it again and read out what you are doing with each
line to find out what you /want/ to do and what you are /actually/ doing.

hth
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: penny336 | last post by:
dear all, i wrote a class integerSet which contain element as integer here is the driver program main IntegerSet a( n ); a.inputSet(); IntegerSet b (a); IntegerSet c(2*n); c =...
12
by: Bryan Parkoff | last post by:
CMain Class is the base class that is initialized in main function. CA Class is the base class that is initialized in CMain::CMain(). CMain Class is always public while CA Class is always...
1
by: Anton Pervukhin | last post by:
Hi everybody! While trying to implement a generic sorting function which takes a member function(on which base the actual sort happens) as a parameter, I have met the problem that I need to use...
7
by: Mike D. | last post by:
I have a problem with a dynamic library I am developing, but it is really more of a pointer issue than anything else. Hopefully someone here can lend me some assistance or insight into resolving...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
4
by: Paulo Matos | last post by:
Hi all, I'm trying to work out a parser for function declarations but it turns out that it is harder than I initially thought. I'm looking at 3rd Ed of Stroustrup, page 808. I'm trying to parse...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
9
by: lucifer | last post by:
Hi I have a little problem regarding inline functions ,does declaring a function inside the class definition make it inline or not.
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
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...
0
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...
0
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,...

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.