[-] mcmodknower@programming.dev 4 points 2 months ago

You want to find a way to remove the "open other programs" permission from the terminal. Or run it in a VM without internet connection.

[-] mcmodknower@programming.dev 4 points 3 months ago* (last edited 3 months ago)

For saving the history inside of one program run, an array is enough. For saving the history over multiple program runs (over closing by typing and invalid character or ctrl+c and restarting it), you would need to store it in a file.

You can already print the last conversion by reading the value of f_value/c_value without writing to it (note that if no conversion of that type has happened before, you will get garbage, and that you will have to modify the if at the start of the loop to check for 'x' too):

		if (choice == 'x') {  // x is the letter left of c, so i chose it as an easy example
			// we want to print the previous conversion, so we don't want to read in a new value.
			// printf("\nEnter the temperature in Celcius: ");  
			// scanf("%d", &c_value);  
			// you might need to comment this getchar() back in so your program skips over the enter after the x, but i am not sure.
			// getchar();  
			// no modification of the following line is needed, as the c_value of the last celcius conversion was never written too and as such still exists.
			printf("\n%d degrees Celcius is %.1f degrees Fahrenheit.\n", c_value, toFahrenheit(c_value));  
		}  

For a longer history you need some extra places to store the numbers. if you use an array, you need to store the length of the history too, since c does not store how far into the array you have written.

// at the start of your main function, where you also declare the other variables
	// allocate the array with fixed length
	int last_c_values[16];
	// and store how many values you've written to it. Initialize it to zero so you don't do garbage with it later on.
	int last_c_values_count = 0;

// after printing the conversion from celsius to farenheit
			if (last_c_values_count < 16) // we can't handle a history longer than that yet
				// copy over the current value into the array, the first one will be at index 0
				last_c_values[last_c_values_count] = c_value;
				// increase the counter so the next value will be at the next place
				last_c_values_count = last_c_values_count + 1;
				// or shorter: last_c_values_count++;
			}

//and the new choice for printing the stuff
		if (choice == 'x') {  // x is the letter left of c, so i chose it as an easy example
			// start at 0, as long as i is below last_c_values_count, increment i by one at the end of each loop run
			for (int i = 0; i < last_c_values_count; i++) {
				// copy the value from last_c_values at index i into c_value
				c_value = last_c_values[i]; 
				// and do the same calculation as before again.
				printf("\n%d degrees Celcius is %.1f degrees Fahrenheit.\n", c_value, toFahrenheit(c_value));  
			}
		}

PS: the for loop in here is equivalent to the following while loop:

			int i = 0;
			while (i < last_c_values_count) {
				// copy the value from last_c_values at index i into c_value
				c_value = last_c_values[i]; 
				// and do the same calculation as before again.
				printf("\n%d degrees Celcius is %.1f degrees Fahrenheit.\n", c_value, toFahrenheit(c_value));  
				i++;
			}
[-] mcmodknower@programming.dev 5 points 10 months ago

Assuming the ballroom costs $200, and a big mac costs $8.39, the answer is 23.837902.

[-] mcmodknower@programming.dev 5 points 11 months ago

Thank you (and the two others also explaining it)

[-] mcmodknower@programming.dev 4 points 11 months ago

Ok, that is something i didn't know. What is the connection between rice and racism here?

[-] mcmodknower@programming.dev 4 points 1 year ago

vim -> back to emacs

[-] mcmodknower@programming.dev 4 points 1 year ago

If the music is your only problem, you are on linux, and you are not afraid of the commandline, you could try mixing the music into your mic audio. But idk how good that works for voice activation. Anyway, here is a related link to the arch wiki (also works on other distros): https://wiki.archlinux.org/title/PulseAudio/Examples#Mixing_additional_audio_into_the_microphone's_audio

[-] mcmodknower@programming.dev 5 points 2 years ago

the other articles looks like its an onion thing

[-] mcmodknower@programming.dev 5 points 2 years ago

Flourescent sea itself is a known thing. But does it exist on the northern hemisphere in latitudes consistent with this view of the big dipper?

[-] mcmodknower@programming.dev 4 points 2 years ago

My smartphone only showed black in the picture :(

[-] mcmodknower@programming.dev 4 points 2 years ago

Use netcat (nc) or similar for local unencrypted one to one chats (half joking)

view more: ‹ prev next ›

mcmodknower

0 post score
0 comment score
joined 3 years ago