Skip to content

Instantly share code, notes, and snippets.

@darkodemic
Last active June 3, 2017 11:40
Show Gist options
  • Save darkodemic/6b59a20fd27f7dbc8f08a3360d0aefe6 to your computer and use it in GitHub Desktop.
Save darkodemic/6b59a20fd27f7dbc8f08a3360d0aefe6 to your computer and use it in GitHub Desktop.
OP drugi zadatak neka godina
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define ROW 4
#define LINE 80
#define FULLARR (ROW * LINE) // Malo macro play-a
int main() {
char s[FULLARR];
char temp[FULLARR];
int optionsCount = 0;
unsigned int option = 0;
int lastPosition = 0;
printf("Unesite red znakova: ");
fgets(s, FULLARR, stdin);
while (optionsCount < 4) {
optionsCount++;
printf("Odaberite opciju: \n"
"1. Novi\n"
"2. Dodatak\n"
"3. Izlaz\n"
"Opcija: "
);
scanf("%d", &option);
getchar(); // da pojede enter
if (option <= 0 || option > 3 ) {
printf(stderr,"Nevazeca opcija odabrana. Ponovite.\n");
continue;
}
switch (option) {
case 1:
printf("Unesite red znakova: ");
fgets(s, FULLARR, stdin);
break;
case 2:
printf("Unesite red znakova: ");
fgets(temp, FULLARR, stdin);
strcat(s, temp);
break;
case 3:
printf("Uneti string je -----\n%s", s);
exit(1);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment