Questions tagged [strcat]

A standard C function that appends a copy of the source string to the destination string.

The declaration of strcat function which is found in string.h is:

char *strcat(char *dest, const char *src)

This function appends the string pointed to by src to the end of the string pointed to by dest. Here,dest is a pointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string and src is the string to be appended. This should not overlap destination.

strcat returns a pointer to the resulting string dest.

For more information, check the man page.

529 questions
-2
votes
3 answers

strcat function how to use

I am pretty new in C language. I am trying to use strcat, the following example works: char s1[20] = "Happy "; char s2[15] = "world"; char s3[40] = ""; strcat(s3,s1); Although, i wanted to practise a bit the pointers i have seen earlier,…
iol
  • 27
  • 1
  • 9
-2
votes
1 answer

Search my name in statement ! in c program using string functions

I need to know whats wrong with this code. #include #include int main() { char a[50], b[100], c[5000]; char *ret; //enter first name gets(a); //enter secend name gets(b); //enter statement …
-2
votes
2 answers

Creating string in C

I'm trying to create in Texas Instrument CCS a string in C like this : {steps: nSteps} in order to send it as a json, nSteps is an int .I want to convert into a string as well with the following code: void jsonSteps(char* stepstr, int steps) { …
user4852783
-2
votes
1 answer

I'm trying to create my own strcat() function instead of implementing the one using the library

//this is my own function, when i call it nothing shows up on the screen char * strcat1(char * destination, const char * value) { while(*destination != '\0') destination++; while(*value != '\0') { *destination = *value; destination++; …
user4154971
-2
votes
1 answer

Getting segmentation fault when using pointers in C

I'm currently working on a project where I want to use SQLite to store some data. Everything is working well except when I want to insert new data into the table. When I run the application, I get segmentation fault, but I can't find the problem. …
user2466860
  • 67
  • 1
  • 2
  • 13
-2
votes
2 answers

Segmentation Fault in C. Trying to concatenate the command line arguments

I'm trying to concatenate the command line arguments into a string. I used the pointer of character type to declare the string initially. char *str; strcpy(str, argv[1]); int i = 2; while(i < argc) { realloc(str, sizeof(str) +…
iMinion
  • 11
  • 3
-2
votes
3 answers

Joining 8 strings to form 1 string in C

I am doing a C programming school project. In one part of the project, I need to join every 8 strings (each 4 characters in length) to form 1 string (each 32 characters in length). For example, char *holdBinary[16] holds 16 strings such…
Begumm
  • 69
  • 1
  • 2
  • 11
-2
votes
6 answers

How to combine three char to one

I had three char inside the array , which contain X1 X2 and X3 char array[3]={X1,X2,X3} I want to combine three data which inside the array to one char strcat(array[0]," "); strcat(array[0],array[1]); strcat(array[0],"…
user2321372
  • 19
  • 1
  • 1
  • 2
-2
votes
1 answer

strcat into char[]

I am using argp in a program and it uses a globally defined char doc[] to display information about the program. Apart from program information, I want to add a GPL notice to this doc. The GPL notice is defined as a const char * ( but I wouldn't…
Jayanth Koushik
  • 9,476
  • 1
  • 44
  • 52
-2
votes
2 answers

Programming segfaulting in strcat()

I am trying to write a web server in C and my code is segfaulting at the moment and I have no idea why. It seems to have something to do with my strcats but thats as far as I've been able to get. I have posted the code and the gdb output. Any help…
zanlura
  • 3
  • 2
-2
votes
2 answers

My strcat doesn't return a value?

I coded a strcat function. But my function doesn't run in this way -----> char * mystrcat(char *s,char *t). I want to return a pointer. Can you help me? #include void mystrcat(char *s,char *t) { while(*s!='\0') s++; …
user1946383
  • 1
  • 1
  • 2
-2
votes
1 answer

Unwanted character being added to string in C

I have a program that gives you shipping addresses from an input file. However at the beginning of one of the strings, order.add_one, a number is being added to the beginning of the string, that number is equivalent to the variable "choice" every…
Church
  • 115
  • 2
  • 3
  • 11
-3
votes
5 answers

C application falling over on strcat

My application falls over when I make the following call to strcat any ideas why? char *encryptedLine[255] = {0}; char encryptedLString[8]; sprintf(encryptedLString, "%08lX", L); strcat(*encryptedLine, encryptedLString);
Dunc
  • 7,688
  • 10
  • 31
  • 38
-3
votes
3 answers

C - string concatenation with pointers

why does the following string concatenation does not work? main() { char *str1 = "United"; char *str2= "Front"; char *str3; str3 = strcat(str1, str2 ) ; printf("\n%s",str3 ); } I got this problem in exercise questions in one of a book on pointers.…
-3
votes
1 answer

How do you call a function that takes in a MAT file, manipulate the data in that file, and create a new textfile with that same MAT file name?

The filename in question is a MAT file that contains elements in the form of "a - bi" where 'i' signifies an imaginary number. The objective is to separate the real, a, and imaginary, b, parts of these elements and put them into two arrays.…
Steve Cho
  • 431
  • 2
  • 5
  • 10