import\export values from\info function

Hi all,
I've a tiny problem with there..
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <stdlib.h>
void testfunc (int x,int len) {
     len=10000;
        printf("%d\n", x);
return (len);// warning: 'return' with a value, in function returning void
}
int main (int argc, char *argv[]) {
int len;
        if (argc>2) testfunc(atoi(argv[2]), len );

printf("%d\n", len);
}

Please, suggest me which's way to take what I mean.
Just i want took and put value into one function. When I tried compile this code have been warning and as expected return(len) doesn't work. Advice me how to fix it?
If your function is declared void it shouldn't return a value, change it to int testFunc
i dont think you can return with void()
change
 
void testfunc (int x,int len)

to
 
int testfunc (int x,int len)
If you want to change the value of len, use references:
void testfunc (int x,int &len)
or pointers: void testfunc (int x,int *len)
Last edited on
Topic archived. No new replies allowed.