strcat() dumping core


 
Thread Tools Search this Thread
Top Forums Programming strcat() dumping core
# 1  
Old 08-21-2008
strcat() dumping core

strcat dumping core in the situation like

main()
{
char* item;
char* p=sat_item;
char type[5];

item=(char*) malloc(strlen(p));
strncpy(type,p,4);
type[4]='\0';

strcat(item,type); //dumping core
}

I couldn't get why strcat dumping core?
# 2  
Old 08-21-2008
For one I cannot find where sat_item is declared. Could the post the whole code?
# 3  
Old 08-22-2008
strcat dumping core

char*p = "sat_item"; // where sat_item is token using strtok()
# 4  
Old 08-22-2008
strtok() might be returning NULL. Did you check it?

The code will work if p points to a string like "sat_item".
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

strcat in C

Hello, #include <stdio.h> #include <string.h> void main() { char tab={"12"}; FILE *outfile; char *outname = "/home/dir/"; printf("%s",strcat(outname,tab)); outfile = fopen(strcat(outname,tab), "w"); if (!outfile) { printf("There was a problem opening %s for writing\n", outname); ... (2 Replies)
Discussion started by: chercheur857
2 Replies

2. Red Hat

Core Dumping?

How to now if the server is core dumping into the same filesystem? (4 Replies)
Discussion started by: 300zxmuro
4 Replies

3. Programming

strcat outputs garbage

Anyone have any ideas why when using strcat function I would get some garbage at the beginning of the output string? what I'm doing is something like the following example. Code: char temp; char tempHolder; for(int i=0;i<something;i++){ sprintf(temp,"%u ", someVariable);... (2 Replies)
Discussion started by: airon23bball
2 Replies

4. Shell Programming and Scripting

strcat equivalent in shell scripting

Hi all, How does string concatenation work in shell scripting? I basically have a variable called "string" and I want to add the strings "aaa" "bbb" "ccc" "ddd" to the variable "string". These strings would be added based on some conditions and separated by spaces . So "string" might look... (8 Replies)
Discussion started by: felixmat1
8 Replies

5. Programming

`strcat' makes pointer from integer without a cast

A question to ask. seq1 = "eeeeeeeeeeeeeeeeee"; seq2 = "dddddddddddddddddddd"; char a = '*'; strcat(*seq2, &a); strcat(*seq1, seq2); compilation warning: passing arg 1 of `strcat' makes pointer from integer without a cast thanks (4 Replies)
Discussion started by: cdbug
4 Replies

6. HP-UX

script running with "ksh" dumping core but not with "sh"

Hi, I have small script written in korn shell. When it is called from different script, its dumping core, but no core dump when we run it standalone. And its not dumping core if we run the script using "/bin/sh" instead of "ksh" Can some body please help me how to resolve this issue. ... (9 Replies)
Discussion started by: simhe02
9 Replies

7. Solaris

coreadm diasble a process from core dumping

Hello All Is it possible to disable a specific process from core dumping ? In my environment I have 2 bespoke application processes which needs to be stopped from core dumping but any other process should be allowed to core dump. If I do : coreadm -d process it will stop all per processes... (3 Replies)
Discussion started by: baner_n
3 Replies

8. UNIX for Advanced & Expert Users

Dumping multiple Folders

How would i go about dumping my /home/ directory and my /root directory i currently have..... dump -f /root/backup.dp /home/ /root/ ...but dump only seems to see only my first source directory and not the second (/root in this case) anyone know a way around this..or if it is even... (1 Reply)
Discussion started by: Freakytah
1 Replies

9. UNIX for Dummies Questions & Answers

Dumping files to tape

Can anyone please help.... how can I dump just a single file to tape using the ufsrestore command!!! I'm a newbie to unix and It's driving me mad.. Thanks in advance. (2 Replies)
Discussion started by: Jonathan
2 Replies
Login or Register to Ask a Question