funguje
This commit is contained in:
		
							parent
							
								
									b968ad7091
								
							
						
					
					
						commit
						077524217d
					
				| @ -28,8 +28,15 @@ int main() { | ||||
|             endptr++; | ||||
|         } | ||||
| 
 | ||||
|         // Zistenie dĺžky mena
 | ||||
|         int len = strlen(endptr); | ||||
|         if (len == 0 || endptr[len - 1] == '\n') { | ||||
|             printf("CHYBA: Neplatny zapis na riadku.\n"); | ||||
|             return 1; | ||||
|         } | ||||
| 
 | ||||
|         // Alokácia pamäte pre meno študenta
 | ||||
|         char* meno = malloc(strlen(endptr) + 1); | ||||
|         char* meno = malloc(len + 1); | ||||
|         if (meno == NULL) { | ||||
|             printf("CHYBA: Nepodarilo sa alokovať pamäť.\n"); | ||||
|             return 1; | ||||
| @ -38,6 +45,9 @@ int main() { | ||||
|         // Kopírovanie mena
 | ||||
|         strcpy(meno, endptr); | ||||
| 
 | ||||
|         // Odstránenie konca riadka z mena
 | ||||
|         meno[len - 1] = '\0'; | ||||
| 
 | ||||
|         // Reallokácia pamäte pre ďalšieho študenta
 | ||||
|         students = realloc(students, (num_students + 1) * sizeof(Student)); | ||||
|         if (students == NULL) { | ||||
| @ -67,5 +77,3 @@ int main() { | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user