Learning by doing: Reading books and trying to understand the (code) examples
				
			 
			
		 
		
		
		
		
		
		
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
				
					
						
						
							|  | #include <stdlib.h> | 
						
						
							|  | #include <stdio.h> | 
						
						
							|  | #include <string.h> | 
						
						
							|  | #include "getline.h" | 
						
						
							|  |  | 
						
						
							|  | 
 | 
						
						
							|  | 
 | 
						
						
							|  | int main(void) { | 
						
						
							|  | 
 | 
						
						
							|  |     // this is wrong -> realloc in trim() on array which wasn't malloc'ed | 
						
						
							|  |     // char blub[] = "    wurstgesicht"; | 
						
						
							|  |     // printf("%s\n", trim(blub)); | 
						
						
							|  |  | 
						
						
							|  |     // by using return value of getline(), we got an array which was malloc'ed | 
						
						
							|  |     char *buffer = trim(getLine()); | 
						
						
							|  | 
 | 
						
						
							|  |     if (buffer == NULL) { | 
						
						
							|  |         printf("%s\n", "out of memory"); | 
						
						
							|  |     } else { | 
						
						
							|  |         printf("%s\n", buffer); | 
						
						
							|  |         free(buffer); | 
						
						
							|  |     } | 
						
						
							|  | 
 | 
						
						
							|  |     return 0; | 
						
						
							|  | 
 | 
						
						
							|  | } |