`strcat' makes pointer from integer without a cast


 
Thread Tools Search this Thread
Top Forums Programming `strcat' makes pointer from integer without a cast
# 1  
Old 11-27-2008
`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
# 2  
Old 11-28-2008
What is your expected output?
# 3  
Old 11-28-2008
#include <string.h>
int main()
{
char *seq1 = "eeeeeeeeeeeeeeeeee";
char *seq2 = "dddddddddddddddddddd";
const char* a = "*";

seq2=(char*)malloc(strlen(seq2)+1);
strcat(seq2,a);
printf("%s",seq2);



return 0;
}
# 4  
Old 11-28-2008
#include <string.h>
int main()
{
char *seq1 = "eeeeeeeeeeeeeeeeee";
char *seq2 = "dddddddddddddddddddd";
const char* a = "*";

seq2=(char*)malloc(strlen(seq2)+1);
strcat(seq2,a);
printf("%s",seq2);

return 0;
}

Is it what you are looking for?
# 5  
Old 11-29-2008
yes. Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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. UNIX for Dummies Questions & Answers

Counting vowels in string. "Comparison pointer-integer".

I'm trying to write a programme which scans strings to find how many vowels they contain. I get an error saying that I'm trying to compare a pointer and an integer inif(*v == scanme){. How can I overcome this ? Also, the programme seems to scan only the first word of a string e.g.: if I type "abc... (1 Reply)
Discussion started by: fakuse
1 Replies

3. Programming

warning: comparison between pointer and integer

Hi guys :D I am still playing with my C handbook and yes, as you can see I have small problem as always :cool: I wrote a C code #include <stdio.h> #define MESSAGE 100 int main(void) { char input_mes - Pastebin.com And when I try to compile it I get following errors from gcc ... (1 Reply)
Discussion started by: solaris_user
1 Replies

4. 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

5. Programming

warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast

I use solaris10,following is tcp client code: #include "cliserv.h" int main(int argc,char argv){ struct sockaddr_in serv; char request,reply; int sockfd,n; if(argc!=2) err_quit("usage: tcpclient <IP address of server>"); if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0) ... (1 Reply)
Discussion started by: konvalo
1 Replies

6. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

7. 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

8. Programming

strcat() dumping core

strcat dumping core in the situation like main() { char* item; char* p=sat_item; char type; item=(char*) malloc(strlen(p)); strncpy(type,p,4); type='\0'; strcat(item,type); //dumping core } I couldn't get why strcat dumping core? (3 Replies)
Discussion started by: satish@123
3 Replies

9. Programming

comparison between pointer and integer

I received a warning when I tried to compile my program that said: warning: comparison between pointer and integer Could you please explain to me what this means, and in what ways I could possibly fix this? Thanks for your help! (2 Replies)
Discussion started by: sjung10
2 Replies

10. Programming

Will we get SEGV if we try to “delete []” un-initialized integer pointer variable.

I have a class with an integer pointer, which I have not initialized to NULL in the constructor. For example: class myclass { private: char * name; int *site; } myclass:: myclass(....) : name(NULL) { ..... } other member function “delete “ the variable before... (2 Replies)
Discussion started by: sureshreddi_ps
2 Replies
Login or Register to Ask a Question