arrays - error while executing sort and search C functions -


I have defined two functions search and sort which are used Another program when I try to run the program, I get an error unexpected input What does the error mean? I do not know what is the problem with my code

  # "helpers.h" # Include / ** * value is true if value is in the array of values, and is false * / Bool search (int value, int value [], int n) {values ​​[n] = n; Return to {if (value [n] == value and & amp; price> gt; 0) for 0 (int i = 0; i & lt; n; i ++); And return 1; } Return 0; } / ** * Sorts an array of values ​​* / zero sort (int value [], int n) {int min, swap; For (int i = 1; i <(n-1); i ++) {min = i; For (int j = i + 1; j; l; n; j ++) {if (value [j]  

This is the main program in which I will call the above two functions

  #include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; # Included "helpers.h" / // maximum volume grass const int MAX = 65536; Int main (int argc, string argv []) {// Ensure proper use if (argc! = 2) {printf ("Usage:. / Needle needle \ n"); Return -1; } // needle intestine needle (argv [1]); // The heap of loaded grass is int size; Int hezstack [max]; (Size = 0; Size & lt; MAX; Size ++) {// EOF Print ("\ nhaystack [% d] =", size) Wait for the grass; Int strow = gateIntent (); If (straw == INT_MAX) {break; } // Add grass to the heap of grass [size] = straw; } Printf ("\ n"); // Sort the green stack sort (histacks, shapes); // If you try to find a needle in the grass covered (search (needle, cheese, shape)) {printf ("\ n a heap of fairy needle! \ N \ n"); Return 0; } Other {printf ("needle not found in \ haystack. \ N \ n"); Return 1; }}  

If this is not causing the error, then it's definitely a In your search function, you have an array of sizes n and access index n , despite having the maximum index n-1 . In addition, your loop in search will always get out without checking anything without scrutching. I highly recommend that you proceed through each line of code and evaluate the values ​​for the variable what happens.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -