mirror of
				https://github.com/eledio-devices/thirdparty-tinyexpr.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Refactored docs.
This commit is contained in:
		
							
								
								
									
										13
									
								
								example2.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								example2.c
									
									
									
									
									
								
							| @@ -20,20 +20,19 @@ int main(int argc, char *argv[]) | ||||
|     int err; | ||||
|     te_expr *n = te_compile(expression, vars, 2, &err); | ||||
|  | ||||
|     if (!err) { | ||||
|     if (n) { | ||||
|         /* The variables can be changed here, and eval can be called as many | ||||
|          * times as you like. This is fairly efficient because the parsing has | ||||
|          * already been done. */ | ||||
|         x = 3; | ||||
|         y = 4; | ||||
|         const double r = te_eval(n); printf("Result:\n\t%f\n", r); } | ||||
|     else { | ||||
|         x = 3; y = 4; | ||||
|         const double r = te_eval(n); printf("Result:\n\t%f\n", r); | ||||
|  | ||||
|         te_free(n); | ||||
|     } else { | ||||
|         /* Show the user where the error is at. */ | ||||
|         printf("\t%*s^\nError near here", err-1, ""); | ||||
|     } | ||||
|  | ||||
|     /* te_free is safe to call on null. */ | ||||
|     te_free(n); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user