?
Solved

strcat() -- segmentation fault Core Dumping

Posted on 2003-02-25
5
Medium Priority
?
671 Views
Last Modified: 2008-03-06
0
Comment
Question by:Deepikak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Expert Comment

by:muskad202
ID: 8023862
the destination string doesn't have enough memory (space) allocated to it..
0
 
LVL 1

Expert Comment

by:brazulewicz
ID: 8026404
complete strcat example:

char *buffer;

buffer = (char*) malloc(1024);
memset(buffer, 0, 1024);

strcat(buffer, "initial strcat\n");
strcat(buffer, "another strcat\n");

0
 

Accepted Solution

by:
plushey earned 100 total points
ID: 8129194
You are obviously trying to address some memory that is out of bounds. This can either be because:
1. The target string doesn't have enough free space to concatenate the second string.
2. The target string is not null terminated or has not been initialised.
3. The target string address in not valid.

HTH
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10018420
Nothing has happened on this question in over 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by plushey (even though it was late it was most comprehensive).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question