Sponsored Content
Full Discussion: Memory Fault,Core dumped
Top Forums Programming Memory Fault,Core dumped Post 302203881 by usshell on Tuesday 10th of June 2008 05:51:47 AM
Old 06-10-2008
Memory Fault,Core dumped

I have written a code in UNIX which is complied by using g++. Compling with turbo C didnt yield any errors, but with g++ I am getting Memory fault, core dumped. Could anyone help me out with this?

Given below is the code:

Code:
#include<stdio.h>

#include<string.h>
#include<stdlib.h>
#include<ctype.h>
main()
{
long int lt;
int i,r=0,p,m=0,q=0;
char a[100];
char *str;
//a=(char*) malloc(sizeof(char) *100);
str=(char *)  malloc(sizeof(char) *100);


scanf("%s",str);
p=strlen(str);
for(i=0;i<p;i++)
{
        if(isdigit(str[i])==0)
        {
        if((str[i]!='.')&& str[i]!='-')
       {
        m=1;
        }
        }
}
for(i=0;i<=p;i++)
{
        if(str[i]=='-')
        r=r+1;
}
for(i=0;i<=p;i++)
{
        if(str[i]=='.')
        q=q+1;
}
lt=atol(str);
if(p>=16 || strcmp(str,NULL)==0 || m==1 || r>1 ||q>1 || lt==0)
{
printf("ERROR");
}
else
{
//ltoa(lt,a,10);
sprintf(a,"%l",lt);
printf("%s",a);
}
}


Last edited by vino; 06-10-2008 at 09:35 AM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Segmentation fault (core dumped)

Hello To All! Now anfd then I receive a message on my console: Segmentation fault (core dumped) What does it mean? Or more precisely what are the implications? :confused: (1 Reply)
Discussion started by: Ivo
1 Replies

2. Programming

Segmentation Fault (core dumped)

what r the situations to receive an error msg like the one below Segmentation Fault (core dumped) (2 Replies)
Discussion started by: bankpro
2 Replies

3. UNIX for Advanced & Expert Users

Memory Fault - Core Dumped

I use SCO UNIX 5.07 on a Compaq Proliant Machine. Each time I press the Escape or Delete key while running a program or issuing a FoxBase+ command from the dot prompt, I receive the error message: "Memory Fault - Core Dumped" and the screen locks up immediately. I would appreciate if necessary... (0 Replies)
Discussion started by: bayuz
0 Replies

4. Solaris

Segmentation Fault (core dumped)

i am getting Segmentation Fault (core dumped) on solaris, but when i run the same program with same input on linux it runs successfully. How can i trace the fault in program on solaris. (6 Replies)
Discussion started by: junaid.nehvi
6 Replies

5. UNIX for Dummies Questions & Answers

Segmentaion Fault - Core dumped during cpio

The same cpio script has been working for years without modifications, until the last couple of nights when we get the error Segmentation Fault - core dumped and the cpio aborts. It appears to abort in relatively the same place every time and on multiple tapes. Do I have a bad tape drive,... (8 Replies)
Discussion started by: golfs4us
8 Replies

6. Solaris

segmentation fault core dumped

i am getting segmentation fault (core dumped) i tried following things but couldn't understand what is wrong with my prog and where the problem is.... i have only adb debugger available on solaris.... so plz help bash-3.00$ pstack core core 'core' of 765: ./mod_generalised_tapinread... (4 Replies)
Discussion started by: junaid.nehvi
4 Replies

7. Red Hat

Segmentation fault (core dumped)

Hi All, I am getting "Segmentation fault (core dumped)" error in the runtime. I am new this please can you tell me why is that i am getting this error and I am not sure of my compilation : gcc -c avc_test.c gcc -c md5.c gcc avc_test.o md5.o -shared -Llibcoreavc_sdk.so -o proj ... (1 Reply)
Discussion started by: fido.genial
1 Replies

8. Programming

Memory Fault (core dumped) in ttpy program

I´m writing this program in QNX , I`m kinda new to UNIX and programing in general, and when I try to run it it gives me the Memory Fault error. Can anyone help? #include <stdio.h> #include <fcntl.h> void main(void) {int a,ter; char buf; printf("a="); scanf("%d",a); ter=open... (6 Replies)
Discussion started by: GiganteAsesino
6 Replies

9. Programming

C: Memory Fault (core dumped)

When I run programm show this message: Memory Fault (core dumped) Does anyone can help me and tell me what is wrong? please #include <stdlib.h> #include <stdio.h> #include <process.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> int main(int argc, char *argv) { ... (3 Replies)
Discussion started by: ebasse2
3 Replies

10. UNIX and Linux Applications

Tilda Segmentation fault (core dumped)

Can anyone tell me why I keep getting a Segmentation fault when I try to run tilda? $ tilda Segmentation fault (core dumped) It seemed to run after I deleted my tilda directory like this thread said to do. Unfortunately it wouldn't let me set my keybinding with anything I tried. ... (0 Replies)
Discussion started by: cokedude
0 Replies
core(4) 						     Kernel Interfaces Manual							   core(4)

NAME
core - format of core image file DESCRIPTION
The HP-UX system writes out a file containing a core image of a terminated process when certain signals are received (see signal(5) for the list of reasons). The most common causes are memory violations, illegal instructions, floating point exceptions, bus errors, and user-gen- erated quit signals. The core image file is called and is written in the process's working directory (provided it is allowed by normal access controls). A process with an effective user ID different from its real user ID does not produce a core image. The file contains sufficient information to determine what the process was doing at the time of its termination. Core file contents con- sist of objects that represent different segments of a process. Each object is preceded by a data structure, and each data structure describes the corresponding object following it. The structure is defined in and includes the following members: The space and addr members specify the virtual memory address in the process where the described object began. The len member is the length of the object in bytes. The following possible values for type are defined in Process data as it existed at the time the core image was created. This includes initialized data, uninitialized data, and the heap at the time the core image is generated. A compiler-dependent data structure containing the exec data structure, the magic number of the executable file, and the command (see the declaration of the structure in The version number of the core format produced. This number changes with each HP-UX release where the core format itself has changed. However, it does not neces- sarily change with every HP-UX release. can thus be easily used by core-reading tools to determine whether they are compatible with a given core image. This type is expressed by a four-byte binary integer. The null-terminated version string associated with the kernel at the time the core image was generated. An architecture-dependent data structure containing per-process information such as hardware register contents. See the declaration of the structure in Process stack contents at the time the core image was created. Objects dumped in a image file are not arranged in any particular order. Use information to determine the type of the object that immedi- ately follows it. SEE ALSO
adb(1), coreadm(1M), coreadm(2), setuid(2), crt0(3), end(3C), signal(5). core(4)
All times are GMT -4. The time now is 08:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy