Initialization
This commit is contained in:
		
							parent
							
								
									63d0ca3727
								
							
						
					
					
						commit
						d091201320
					
				@ -27,6 +27,7 @@ int compare(const void *a, const void *b) {
 | 
			
		||||
int main() {
 | 
			
		||||
    struct student students[SIZE];
 | 
			
		||||
    int size = 0;
 | 
			
		||||
    int successful_lines = 0; // Counter for successful lines read
 | 
			
		||||
 | 
			
		||||
    // read student data from standard input
 | 
			
		||||
    while (1) {
 | 
			
		||||
@ -43,14 +44,17 @@ int main() {
 | 
			
		||||
        // parse the string and extract number of votes and student name
 | 
			
		||||
        int votes;
 | 
			
		||||
        char name[SIZE];
 | 
			
		||||
 | 
			
		||||
        // Attempt to parse the input line
 | 
			
		||||
        if (sscanf(line, "%d %[^\n]", &votes, name) != 2) {
 | 
			
		||||
            // Error: Unable to parse input line
 | 
			
		||||
            printf("Nepodarilo nacitat nic\n");
 | 
			
		||||
            return 1; // Exit with error code
 | 
			
		||||
            if (successful_lines >= 1){
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                printf("Nepodarilo nacitat nic")
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        successful_lines++;
 | 
			
		||||
 | 
			
		||||
        // check if this student already exists
 | 
			
		||||
        int found = 0;
 | 
			
		||||
        for (int i = 0; i < size; i++) {
 | 
			
		||||
@ -80,4 +84,4 @@ int main() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user