1

Topic: Structures, a program error....

Good evening. There was a program error, it is not known because of what  stops operation, after data input. It was still tangled as to solve the job completely, a condition:
Structure  an array a toy: a title, the price, an age range - the upper edge, lower.
To define: title of the most expensive toy, the list of toys which approach children of the given age to pick up toys on  a subject the total of money.

Here the code.

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main ()
{int n, i, c;
int v;
setlocale (LC_ALL, "russian");
float maxc;
struct igr
{char name [20];
float cost;
int vozrn;
int vozrv;
};
struct igr toy;
printf ("Enter an amount of toys");
scanf ("%d" ,&n);
for (i=0; i <n; i ++)
{
printf ("Enter a title");
scanf ("%s" ,&toy.name);
printf ("Enter cost");
scanf ("%s" ,&toy.cost);
printf ("Enter age lower bound");
scanf ("%s" ,&toy.vozrn);
printf ("Enter age upper bound");
scanf ("%s" ,&toy.vozrv);
printf ("\n");
}
printf ("Enter age of the child \n");
scanf ("%d", v);
printf ("Enter the price");
scanf ("%d", c);
for (i=0; i <n; i ++) {
toy.cost> maxc;
maxc=toy.cost;}
printf ("the Ceiling price %f %s", maxc, toy.name);
return 0;

Help please...

2

Re: Structures, a program error....

cnainik wrote:

Help please...

Debugger in hands and  transit all program, looking values of variables. Search for a place,
Where your waitings start to differ from a reality.

3

Re: Structures, a program error....

But before it include show of all warnings by the compiler and attentively read that it
To you writes.

4

Re: Structures, a program error....

cnainik;
Function scanf in quality in parameter accepts addresses of variables, as it is logical. At you it not so

5

Re: Structures, a program error....

Dimitry Sibiryakov, I am sorry, did not think that you try to let chance of the hardware think (

6

Re: Structures, a program error....

cnainik, esteem the function description scanf , there explicitly it is written how to enter values. Briefly:
* The whole values it is entered with the help %d:

int age;
scanf ("%d", &age);//' and ' we write, ' &age ' - the pointer on a variable age

* Fractional values it is entered with the help %f:

float cost;
scanf ("%f", &cost);//' and ' we write, ' &cost ' - the pointer on a variable cost

* String values it is entered with the help %s:

char name [100];
scanf ("%s", name);//' and ' we do not write, the array name implicitly will be transformed to the pointer on the first element of this array