My programm wont let me input all the data I need. And when I try to display them it won't even use the data that I could input. Please help me and sorry for my bad English it is not my native language, that's why all the data is in Slovene. Thanks for any help that I will get.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct student 

       char vpisna_st[8]; 
       char ime[20];
       char priimek[20];
       int starost;

}stud;


int main()
{
  struct student stud;  
  printf("Vnesite vase podatke. \n");
  printf("Vpisna stevilka: ");
  scanf("%c",&stud.vpisna_st); 
  printf("Ime: ");
  scanf("%c",&stud.ime);
  printf("Priimek: ");
  scanf("%c",&stud.priimek);
  printf("Starost: ");
  scanf("%d",&stud.starost);


  printf("Student je:\n vpisna st: %c, \n ime: %c, \n priimek: %c, \n starost: %d \n", stud.vpisna_st,stud.ime,stud.priimek,stud.starost);  
  system("PAUSE");  
  return 0;
}{

"%c" only gets one character from the keyboard. I see the structure contains several character arrays, so "%s" is probably more appropriate. Also, it's not necessary to use & before character arrays because they are already passed as pointer by default. For example

scanf("%s",stud.vpisna_st);

Thank you verry much. It helped a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.