[Solved] How to read line by line from file

As you saw, your function read_ins is always outputting the first line of your file program.txt. This is because each time you open the file using fopen, the read cursor is starting from the beginning of the file. To change this behavior, you should open the file and give the FILE* as an argument of … Read more

[Solved] MySQL Joining a Table twice

SUM does not take two parameters like you did in sum(fleuge1.Preis,fleuge2.Preis) sum is an aggregate function , meant to sum all the values on a column, if you want to sum two values from a two distinct sets just do fleuge1.Preis+fleuge2.Preis if you want to post errors on stack overflow you can just copy them … Read more

[Solved] Haskell, tuple (double, string) [closed]

You can implement it using mapM_/traverse_ or the flipped argument versions: forM_/for_. I prefer for_ since it looks more like the “enhanced for-loop” from languages like Java. import Data.Foldable (for_) myPutStr :: [(Double,String)] -> IO () myPutStr vals = do for_ vals $ \(num, str) -> do putStr str putStr “: ” print (num * … Read more

[Solved] How to get rid of “\n” and ” ‘ ‘ ” in my json file

The fundamental issue is that you’re creating multiple JSON strings (json_data = (json.dumps(response, indent=2))) and then adding them to an array (json_arr.append(json_data)), and then converting that array to JSON (json.dump(json_arr,outline)). So the result is a JSON array of strings (containing JSON). You don’t want to create a string before adding to the array, just include … Read more

[Solved] How to plot a math function from string?

You can turn a string into code by using pythons eval function, but this is dangerous and generally considered bad style, See this: https://stackoverflow.com/a/661128/3838691. If user can input the string, they could input something like import subprocess; subprocess.check_call([‘rm’, ‘-rf’, ‘*’], shell=True). So be sure that you build in reasonable security into this. You can define … Read more