ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#include <stdio.h>
#include <fenv.h>
/*#include <float.h>*/
/*#this program is a proof of concept. It will be used to:
#first create n^n for numbers 2-127 in binary
#second assign the binary of the numbers in an array "NthArray"*/
void main()
/*#loop to fill the array*/
{
int count;
int i;
long double res=1;
long double NthArray[10];
for (count = 0; count <= 127; count++)
{
res=1;
for (i=1; i <= count; i++)
{
/*printf ("i=%d\n",i );*/
res = res * count;
/*printf ("res=%f\n",res );*/
}
NthArray[count] = res;
printf ("Count=%d",count );
printf (".");
printf ("The Nth = %Lf\n",NthArray[count]);
}
res=1;printf("table loaded\n");
}
This bit of code complies fine but when I run it I get:
gdb ./nth -c mydump.txt
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/jason/Documents/programming/nth...done.
"/home/jason/Documents/programming/mydump.txt" is not a core dump: File format not recognized
(gdb) run
Starting program: /home/jason/Documents/programming/./nth
Count=0.The Nth = 1.000000
Count=1.The Nth = 1.000000
Count=2.The Nth = 4.000000
Count=3.The Nth = 27.000000
Count=4.The Nth = 256.000000
Count=5.The Nth = 3125.000000
Count=6.The Nth = 46656.000000
Count=7.The Nth = 823543.000000
Count=8.The Nth = 16777216.000000
Count=9.The Nth = 387420489.000000
Count=10.The Nth = 10000000000.000000
...............
Count=127.The Nth = 1524307411995722575737095034367932617400955458112824476089134616001097797110416587846022345778082377 2948777596941440497539534786314040488562210183714084842392119548923554743813133193657360180665611222 92345542412230225506634371181613735575034509047146723374175939985408.000000
table loaded
Program received signal SIGSEGV, Segmentation fault.
0x00004025 in ?? ()
(gdb)
I'm not sure why it doesn't like my back trace file. Since it point to an open "()"
I'm not sure where to go next. I have googled "0x00004025" to no avail, I'm sure it a simple error between the keyboard and the chair but I'm stuck, any Ideas?
Coredump files are usually called just coredump, no extension. Also check that you have coredumps enabled (ulimit -c). Although if you can just run the program in the debugger and reproduce the error directly (like you've done), that's usually easier.
Your backtrace only has 1 frame in it, probably because your program has corrupted the stack so a backtrace cannot be constructed.
Also make sure to compile with debug information (pass -g to gcc), otherwise your backtraces will have only raw addresses, and no function names, or line numbers.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.