omg....thx... stupid mistake...lol
Type: Posts; User: vince3214
omg....thx... stupid mistake...lol
sry is not causing seg fault any more... just print some random stuff in the first line of my result.txt
I'm designing a program for appending a few lines at certain line from a file.
the procedure is read from a file & store the lines into a link list, append at certain line then write it to...
hmm thx a lot ~but still i wanna learn how to use debugger properly :) i think i didn't install it, i thought it was within cygwin
so what should i type in after compile?
shouldn't it be gdb./mycode ?
but command not found from cygwin
also i dont really understand the message from debugger ;(
Yea I think learning how to use debugger is really important but I dont know how to install it into my computer(i have compiler though, call "cygwin")
the only place i can use debugger is at school...
:frown:
I'm making a line editor(for a file) & up tp append function.(type in "a")
the append function is to append something after the current line.
im now getting seg fault but cant really find...
well assume input is a string and compare with "\n"
if my input is return(enter), is it gonna return 0?
by using strcmp i think it's not working
strcmp(input,"\n");
can anyone help?
thanks a lot. my problem seems to be reading the file each time i call ScanInput;
this is my code & its design for reading a file and edit. and we can type in various command like "p" print out the data in file(which is the one cause the problem).
also,does -g mean using gdb to...
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NUMBERLINES 1000 // max number of lines that can be read
#define LINELENGTH 1000 // max length of a line
#define FNAMELENGTH...
What will cause this kind of problem? I know it might be helpful to bring up my code. But it's pretty much a mess.
*** glibc detected *** ./led: malloc(): memory corruption: 0xb77e67bf ***...
*every
should I initialize ever s->next = NULL then give them value in the loop?
oh wait..the problem occur after the loop, thx a lot for ur help!
I'm not quite getting it, say s is a pointer that will go through every nodes in the list, should I do "s = s -> next" to move pointer s to the next node?
if(argv[1] != NULL){
if((fp = fopen(argv[1],"r")) != NULL) {
while (fgets(line, 1000, fp) != NULL) {
s = malloc(sizeof(NodeT*));
strcpy(s->line,line);
s = s->next;...
This is what i got by now
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Node {
char line[1000];
struct Node *next;
i did put them but forgot to post them ;P i free them at the end....but after i malloc those two, im still getting seg fault.
NodeT *s = malloc(sizeof(NodeT* ));
NodeT *head =...
This is my program to read a file & print the lines out,
since im not familiar with link list, i got a seg fault from this.
Anyone can help me out,thx?
#include<stdio.h>...