c - How to resolve the segmentation fault due to strtok()? -


I'm getting a segment error when the bottom line is executed:

  result = Stroke (data, delimiter);  

I have given backtrace:

  Program received signal SIGSEGV, backtrace from segmentation fault 0x44359e85 / lib / libc.so.6 (gdb) 0444 9 885 from strtok () to /lib/libc.so.6 # 1 0x08048c02 in main () multiply.c on: 36  

How to solve it?

There are some reasonable possibilities for partitioning. You have a problem:

  • null as data in the first call on strtok ()
  • passing zero as the delimiter .
  • Using the read-only string as the data, which is forbidden, because strtok () modifies the source string.

I know that you know how to use GDB, so before calling, apply a breakpoint to strtok () and see Which values ​​have been passed to the function.

You can also use Valgrind to help you find a specific problem.

But, if you want a better answer in stack-overflow, then you have to give some more code and other information.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -