c - Implementing a Linear Search -


Question: Read up to 6 pairs of names and ages in two different arrays, and use a linear search Find the target name and print the person's age. Two arrays are called names and ages:

I am getting many errors ... I am sure that the function is not being passed to an array .. < Pre> # include & lt; Stdio.h & gt; # Defined ASIZE 20 # defined RECSIZE 6 string record {char name [ASIZE]; Acute age [ASGE]; }; No record [RECSIZE]; Int linear search (structure record * find A, four *) {int x; (X = 0; x & lt; RECSIZE; x ++) {// if (no [x] .name == [x] get] if (a-> gt; x [x] == [x] looks {Return x;}} return -1;} for int main () {int i; (i = 0; i & lt; RECSIZE; i ++) {printf ("Enter name:"); scanf ("% s", no [i] .name); Printf ("Enter age:"); scanf ("% i", & amp; na [i] .age);} printf ("Enter search name : "); Four floating [ASGE]; scanf ("% s ", temporary [ASIZE]); full results; result = linear search (& amp; not; & amp; temp []); printf ("% i " Please return help;

Please help.

The error is as follows: Results = Linear Search (& amp; No, & amp; Temporary []);

  #include  #include & lt; string.h & gt; ; # Define ASIZE 20 # defined RECSIZE 6 string record {char name [ASIZE]; int age;}; structure record no [RECSIZE]; int linear search (structure record * find A, four *) {int x; (x = 0; x & lt; RECSIZE; x ++) {if (strcmp (a [x] .name, find) == 0) return x; } Return -1; } Int main () {int i; For (i = 0; i & lt; RECSIZE; i ++) {printf ("Enter name:"); Scanf ("% s", na [i] .name); // There is no security when entering buffer printf ("Enter age:"); Scanf ("% i", and [ii] .gg); } Printf ("Enter search name:"); Four temporary [ASIJEE]; Scanf ("% s", temp); Full results; Result = Linear Search (non, temporarily); Printf ("% i", result); Return 0; }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -