Cannnot Convert int to int. Arrays C -
hello having hard time getting arrays work in functions. keep getting error called c2664 "void rannumperm_10(int)' : cannot convert argument 1 'int [10]' 'int'" don't understand how fix it...
function rannumperm_10(int):
void rannumperm_10(int bubble_1[]) { int onerandno; int haverand[array_size_1] = { 0 }; (int = 0; < array_size_1; i++) { { onerandno = rand() % array_size_1; } while (haverand[onerandno] == 1); haverand[onerandno] = 1; bubble_1[i] = onerandno; } return; }
this program unfinished program use bubble, selection, insertion sort algorithms. can't seem populate arrays yet. trying make function being "random number permutation generator" every number random , no number repeats self. use in getting code work , solving error c2664.
full code:
#define _crt_secure_no_warnings #define array_size_1 10 #include <stdio.h> #include <stdlib.h> void rannumperm_10(int bubble_1); int main(void) { //declarations int bubble_1[array_size_1]; //bubble population @ 10 rannumperm_10(bubble_1); (int = 0; < array_size_1; i++) { printf("%d\n", bubble_1[i]); } printf("array population test...\n"); return 0; } void rannumperm_10(int bubble_1[]) { int onerandno; int haverand[array_size_1] = { 0 }; (int = 0; < array_size_1; i++) { { onerandno = rand() % array_size_1; } while (haverand[onerandno] == 1); haverand[onerandno] = 1; bubble_1[i] = onerandno; } return; }
the declaration , definition of rannumperm_10
have conflicting signatures. @ top of full code, declare void (int)
, definition void (int [])
.
Comments
Post a Comment