Function not working

K

KL

I have the following function:

void fillvaluecheck (int valuecheck[], int size){
for (int m = 0; m < size; m++){
cout << valuecheck[m] << endl;
valuecheck[m] = 0;
cout << valuecheck[m] << endl;
}
return;
}

I have the two cout statements only to verify that the function was
working correctly. Well, it is not doing anything that I can tell. I
want to fill my valuecheck array with all zeros. What am I possibly
doing wrong?

KL
 
C

CrayzeeWulf

KL said:
I have the two cout statements only to verify that the function was
working correctly. Well, it is not doing anything that I can tell. I
want to fill my valuecheck array with all zeros. What am I possibly
doing wrong?

Hi KL,

There is nothing specifically wrong with the function itself. However, many
things can go wrong depending on how and with what parameters you call the
function. Please provide a complete program that shows how you call the
function and the output that you obtain.

Thanks,
 
K

Ken Human

KL said:
I have the following function:

void fillvaluecheck (int valuecheck[], int size){
for (int m = 0; m < size; m++){
cout << valuecheck[m] << endl;
valuecheck[m] = 0;
cout << valuecheck[m] << endl;
}
return;
}

I have the two cout statements only to verify that the function was
working correctly. Well, it is not doing anything that I can tell. I
want to fill my valuecheck array with all zeros. What am I possibly
doing wrong?

KL

KL,

Your function itself looks fine. Look at the following code and see if
it helps at all.

$ cat test.cpp
#include <iostream>
using namespace std;

void fillvaluecheck(int valuecheck[], int size) {
for(int m = 0; m < size; m++) {
cout << valuecheck[m] << endl;
valuecheck[m] = 0;
cout << valuecheck[m] << endl;
}
}

int main() {
int valuecheck[10];
fillvaluecheck(valuecheck, 10);
return 0;
}

ken@ken-wn0vf73qmks ~/c
$ ./test
-1
0
2088773120
0
2088772930
0
2089866642
0
2088803259
0
1896
0
2289608
0
1628013867
0
1896
0
-1
0
 
A

Alan Brown

I have the following function:

void fillvaluecheck (int valuecheck[], int size){
for (int m = 0; m < size; m++){
cout << valuecheck[m] << endl;
valuecheck[m] = 0;
cout << valuecheck[m] << endl;
}
return;
}

I have the two cout statements only to verify that the function was
working correctly. Well, it is not doing anything that I can tell. I
want to fill my valuecheck array with all zeros. What am I possibly
doing wrong?

KL

In your call to fillvaluecheck is size greater than zero??

Alan
 
K

KL

Yeppers...it was all the way I was calling it.... Darned functions
anyway.

KL

Ken said:
KL said:
I have the following function:

void fillvaluecheck (int valuecheck[], int size){
for (int m = 0; m < size; m++){
cout << valuecheck[m] << endl;
valuecheck[m] = 0;
cout << valuecheck[m] << endl;
}
return;
}

I have the two cout statements only to verify that the function was
working correctly. Well, it is not doing anything that I can tell. I
want to fill my valuecheck array with all zeros. What am I possibly
doing wrong?

KL

KL,

Your function itself looks fine. Look at the following code and see if
it helps at all.

$ cat test.cpp
#include <iostream>
using namespace std;

void fillvaluecheck(int valuecheck[], int size) {
for(int m = 0; m < size; m++) {
cout << valuecheck[m] << endl;
valuecheck[m] = 0;
cout << valuecheck[m] << endl;
}
}

int main() {
int valuecheck[10];
fillvaluecheck(valuecheck, 10);
return 0;
}

ken@ken-wn0vf73qmks ~/c
$ ./test
-1
0
2088773120
0
2088772930
0
2089866642
0
2088803259
0
1896
0
2289608
0
1628013867
0
1896
0
-1
0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top