Posts by lucas pelepek • 75 points
5 posts
-
0
votes1
answer62
viewsQ: Malloc in a string, based on the size of a FILE
int main(void) { FILE *p = fopen("matriz.txt","r+"); char *arquivo; arquivo=(char*)malloc(sizeof(p+1)*sizeof(char)); while (fgets(arquivo,sizeof(arquivo),p)) { printf(" %s",arquivo ); } }//END the…
-
0
votes1
answer156
viewsQ: Read char matrix from a binary file
Function that writes and reads binary file: int FUNCAO_QUE_GRAVA_BIN (char filename[],int partida1,char resultado1) { typedef struct { int partida; char jogvelha[3][3]; char resultado; } velha;…
-
0
votes1
answer83
viewsQ: "strcpy" behaving strangely depending on how you put it in "if"
What’s going on here? #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> void escolha_simb(char *jog1, char *jog2) //** escolhe quem vai ser x ou o…
-
4
votes3
answers1163
viewsQ: How to separate HTML from PHP
I read in several places that you should not mix PHP with HTML and vice versa, How then could I separate this code for example: <?php include 'C:\xampp\htdocs\trabweb\sessaoBD.php' ?>…
-
2
votes1
answer59
viewsQ: Binary file being misspelled
Creating the binary file: #include <stdio.h> int main(int argc, char const *argv[]) { FILE *BIN; BIN = fopen ("BIN.bin","wb"); if (BIN!=NULL) { for (int i = 1; i <= 100; i++) { fwrite(…