Creative Commons License Foxbond's Repo

/** (c) 2015 Michał (Foxbond) Chraniuk */
#include <stdio.h>

typedef struct student {
  	 			char nazwisko[20];
	 				char imie[20];
	 				char nrIndeksu[10];
	 				float ocena;
}student;

int main (){
		student std;
	 
	 printf("Podaj dane studenta:\nImie: ");
	 scanf("%s", &std.imie);
	 printf("Nazwisko: ");
	 scanf("%s", &std.nazwisko);
	 printf("Nr indeksu: ");
	 scanf("%s", &std.nrIndeksu);
	 printf("Ocena: ");
	 scanf("%f", &std.ocena);
	 
	 printf("\n-----------------\nZapisany student:\nNazwisko: %s\nImie: %s\nNr indeksu: %s\nOcena: %.2f\n", std.nazwisko, std.imie, std.nrIndeksu, std.ocena);
	 
	 student std2 = std;
	 
	 printf("\n-----------------\nPrzypisanie:\nNazwisko: %s\nImie: %s\nNr indeksu: %s\nOcena: %.2f\n", std2.nazwisko, std2.imie, std2.nrIndeksu, std2.ocena);
	 
	 student std3;
	 
	 strcpy(&std3.imie, &std.imie);
	 strcpy(&std3.nazwisko, &std.nazwisko);
	 strcpy(&std3.nrIndeksu, &std.nrIndeksu);
	 std3.ocena = std.ocena;
	 
	 printf("\n-----------------\nStrcpy:\nNazwisko: %s\nImie: %s\nNr indeksu: %s\nOcena: %.2f\n", std3.nazwisko, std3.imie, std3.nrIndeksu, std3.ocena);
	 
	 student std4;
	 
	 memcpy(&std4, &std, sizeof(std));
	 
	 printf("\n-----------------\nMemcpy:\nNazwisko: %s\nImie: %s\nNr indeksu: %s\nOcena: %.2f\n", std4.nazwisko, std4.imie, std4.nrIndeksu, std4.ocena);
	 
	 
	 getch();
	 return 0;
	 }

> Back