Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- typedef struct nod {
- char titlu[25];
- char autor[20];
- char editura[20];
- nod *next;
- }NOD;
- NOD *head = (NOD*)malloc(sizeof(NOD));
- NOD *nodc;
- void citire(int n) {
- nodc = head;
- for (int i = 0; i < n; i++) {
- printf("Titlu: ");
- scanf("%s", &nodc->titlu);
- printf("Autor: ");
- scanf("%s", &nodc->autor);
- printf("Editura: ");
- scanf("%s", &nodc->editura);
- nodc->next = (NOD*)malloc(sizeof(NOD));
- nodc = nodc->next;
- nodc->next = NULL;
- }
- }
- void afisare() {
- nodc = head;
- char aux[10] = "Teora";
- while (nodc->next) {
- if (strcmp(nodc->editura, aux)==0) {
- printf("Titlu: %s\n", nodc->titlu);
- printf("Autor: %s\n", nodc->autor);
- printf("Editura: %s\n", nodc->editura);
- }
- nodc = nodc->next;
- }
- }
- int main() {
- int n;
- printf("Cate carti adaugati?\nn= ");
- scanf("%d", &n);
- citire(n);
- afisare();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment