ok guys thank you for your reply.
yea I think I'll go through printf or gdb with bt. I wanted to be sure about what is the "correct" way to do that
Cheers
Type: Posts; User: Dedalus
ok guys thank you for your reply.
yea I think I'll go through printf or gdb with bt. I wanted to be sure about what is the "correct" way to do that
Cheers
Hello,
I need to test the order in which some functions are called. Other than add a prinf in each function do you know any method/tool that can help me out?
I normally use "check unit test...
Hello
solved!
actually I forgot to include the stdlib.
Moreover the int base is 10 and not 16 as I wrote
thx for the tip
Hi
thx for reply. You're right atoi converts to integer !!
My OS is Redhat 6 and I use gcc. I changed my code by using strtoull instead of atoi and now is better but not perfectly fine:
...
Hello,
When I try to print an unsigned long long int I get a different number displayed.
This is the code I'm using:
int main(int argc, char *argv[]) {
printf ( "ULLONG_MAX: %llu\n",...
Hi
I finally got the error.
It was in how gdb was started, I always did:
gdb test
and then inside gdb
It is not mistery at all. I don't think I'm hiding something
I'm posting all the infos that may needs.
Btw the file it's just 2 lines as I said,
that are:
Yea buf contains a '\n' so gdb should not complain about not finding the newline.
I mean that if (l==NULL) should not be true
That's what I thought but
I used a test file with 2 lines with '\n' at the end.
then I used a program that simply print out the line to be sure that '\n' was there.
this code
int main (int...
Hi I wanted to tell that I found how to avoid the warning.
Just change:
int word=100;
into
size_t word=100;
Moreover someone suggested me to add
Hi
no actually I read it in buf and then I directly look for the '\n'.
Yea you right,
but the problem is that the carriage ret should be there.
The input file simply contains two lines,
do you think that the problem is raised on the second line without '\n'?
Hi Salem thx for your feedback it's really weird.
When I run the code it works always even on different or big txt files without segfault.
Moreover also valgrind give me back a good result:
...
Hi thx for reply
here details:
I include
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Hi all,
I'd like to read a file line by line then remove the carriage ret and print the modified line, here's the code:
int main (int argc, char *argv[]) {
FILE *stream;
int...
Hi
thx for the advice
I see your point. So the cleanest way seems to be:
int num=10;
char *test, *tmp;
int i=0;
Hi
thx all for reply.
I tried to work out a solution.
If I would remove the first letter of a string I could then copy back the rest of the string without modify the pointer and miss the...
Hi,
thx for reply.
Hi,
here there's an example code that creates a memory leak.
My problem is to call free on modified pointer.
int num=10;
char *test;
int i=0;
Hi,
thanks for your help I appreciate it
Hi all,
I know that each time we allocate memory onto the heap (malloc, calloc, realloc..) once we finish we have to free it in order to avoid memory leaks.
Just to improve my skills I'm...
Hello
thanks for sharing your solution.
I use it to parse some text files, usually I use bash but wanted to try C too.
Cheers
Hi,
the method I use is a :
while((c=getc(stream)) != '\n'){
so I read always the entire row
thanks for reply
Hi all,
I have a file which contains some specials chars to gather one for each line. For example if the special char is $ (dollar) the file may looks like:
hello world $ hello
$ hello...
Hi all,
Actually I'm reading some C functions, but I don't understand some notations and sintax, like:
fputs (_("Filesystem Type"), stdout);
for me is not clear why the develop use...