Receiving an exception and code failing when trying to delete a line from a .txt file using java

Advertisements I am trying to delete a specific line from my text file using java, My code is supposed to write the file to a temp file and skip writing the username (chosen to be deleted), it is then supposed to delete the original file and rename the new temp file to match the original.… Read More Receiving an exception and code failing when trying to delete a line from a .txt file using java

Error 'listaCliente' undeclared (first use in this function)

Advertisements I can’t run the code because it gives the error mentioned in the title, but I declared it in main. I’m stuck for a few hours and I can’t solve this main.c , here is where I declare the "listaCliente" int main() { Cliente* listaCliente = lerBaseDeDados(); menuPrincipal(listaCliente); } Cliente.c // menu , basically… Read More Error 'listaCliente' undeclared (first use in this function)

Bad file descriptor fgets

Advertisements I’m trying to create a file to send information to another process. But when I reach the send_file function, I get –>Error in fgets():: Bad file descriptor. Can someone help me address this matter, please? I’m stuck. #include <stdlib.h> #include <stdio.h> void send_file(FILE *fp, int sockfd){ char data[SIZE] = {0}; if (fgets(data, SIZE, fp)… Read More Bad file descriptor fgets

How to calculate sum of multiple responses inside a loop using javascript?

Advertisements I have two loops as shown: for (var i = 0; i < nearPlacements.length; i++) { var meshInstances = nearPlacements[i].model.model.meshInstances; var mat; var matEach = 0; for (var i2 = 0; i2 < meshInstances.length; i2++) { mat = parseFloat(meshInstances[i2].mesh.indexBuffer[0].numIndices / 3); matEach += mat; } console.log(matEach); } console.log(matEach); outputs data as: How to display… Read More How to calculate sum of multiple responses inside a loop using javascript?

Java multiplication table, Writer writes in second line instead of first

Advertisements It’s supposed to be a multiplication table in the shape of a square, but the writer doesn’t write the numbers in the first line and the first column. try { File file = new File("multi.txt"); // FileWriter Writer = new FileWriter("multi.txt"); BufferedWriter Writer = new BufferedWriter(new FileWriter(file)); for (int o = 1; o <=… Read More Java multiplication table, Writer writes in second line instead of first

Valgrind message: Conditional jump or move depends on uninitialised value(s) unresolved

Advertisements i’m trying a new assignment i’ve got: i need to copy the Environment variables from the shell into an array, then lowercase them and print them back. (i’m using Ubuntu 20.04.4 LTS, gcc for compiling, and writing my code in C language). i was adviced to use malloc to create the array but decided… Read More Valgrind message: Conditional jump or move depends on uninitialised value(s) unresolved

How to convert UNIX time stamps (UTC) to broken-down time?

Advertisements I have broken-down time which I then convert to UNIX timestamp in UTC and without DST with _mkgmtime instead of mktime(which applies the local timezone). This works fine. What I now want is to convert the UNIX timestamp generated back to broken-down time exactly the same with no DST/TimeZone changes. I tried using strftime()… Read More How to convert UNIX time stamps (UTC) to broken-down time?

Convert ASCII to hex

Advertisements I want convert ASCII values to hex. In Java, I often use the function: private static String asciiToHex(String asciiStr) { char[] chars = asciiStr.toCharArray(); StringBuilder hex = new StringBuilder(); for (char ch : chars) { hex.append(Integer.toHexString((int) ch)); } return hex.toString(); } Is there any method in Dart to convert to hex value like Integer.toHexString… Read More Convert ASCII to hex