answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

Why strcat(string'!') not work in C program?

The strcat() function has the following protocol:char* strcat (char* destination, char* source);The function appends the source string to the destination string and returns the destination string.The destination string must be a null-terminated character array of sufficient length to accommodate strlen (source) plus strlen (destination) characters, plus a null-terminator. The existing null-terminator and subsequent characters of destination are overwritten by characters from the source string, up to and including the source string's null-terminator.strcat (string, '!') will not work because '!' is a character literal (ASCII code 33 decimal), not a null-terminated character array. Use "!" instead of '!'.Example:char string[80]; // character arraystrcpy (string, "Hello world");strcat (string, "!");puts (string);


What is syntax of memcpy?

memcpy function is used to copy memory area. Syntax ------ void *memcpy(void *dest, const void *src, size_t n); *dest is a destination string. *src is a source string. n is a number of characters to be copied from source string. Example: #include #include main() { char src[]="Hello World"; char des[10]; memcpy(des,src,5); printf("des:%s\n",des); //It will contain the string "Hello". }


How do you write the concatenate the strings using pointer?

char* strcat (char* destination, const char* source) { char* return_value = destination; // temp destination for return while (*(destination++) != '\0'); // find end of initial destination while ((*(destination++) = *(source++)) != '\0'); // copy source to end of destination return return_value; // return original value of destination }


What are 4 string handling function?

strlen(s1) to find the length of the string s1 strcpy(s1,s2) copy source string to destination string(i.e copies s2 to s1,s2 remain unchanged) strcmp(s1,s2) compares s1 and s2 and prints 0 if s1 and s2 are equal,-1 if s2 is greater, 1 if s1 is greater strcat(s1,s2) combines string s1 and s2 to a single word and stores it in s1 strupr() converts lower case string to upper case strlwr() converts upper case string to lower case


Which function joins two arrays of character in c language?

C provides the strcat() function, and its prototype is:char *strcat (char *destination, const char *source);destination must have enough memory allocated for itself and source. If you want to join two character arrays into a newly allocated string, use the following function:char *strcombine(char *str1, char *str2){/* size_t is a standard size or length integer type */size_t len;/* this is the pointer to the new string */char *returnstr;/* figure out the new string length */len=strlen(str1)+strlen(str2)+1;/* allocate memory for the return string and init to a length of 0 */returnstr=(char*)malloc(len);*returnstr=0;/* concatenate str1 and str2 to returnstr */strcat(returnstr, str1);strcat(returnstr, str2);/* return the new string */return returnstr;}Note that typecasting the malloc() return value as (char*) is just a formality under C; under C++, however, it's required to avoid warnings.Also, the above function does not test to see if str1and/or str2 are NULL values.

Related Questions

Why strcat(string'!') not work in C program?

The strcat() function has the following protocol:char* strcat (char* destination, char* source);The function appends the source string to the destination string and returns the destination string.The destination string must be a null-terminated character array of sufficient length to accommodate strlen (source) plus strlen (destination) characters, plus a null-terminator. The existing null-terminator and subsequent characters of destination are overwritten by characters from the source string, up to and including the source string's null-terminator.strcat (string, '!') will not work because '!' is a character literal (ASCII code 33 decimal), not a null-terminated character array. Use "!" instead of '!'.Example:char string[80]; // character arraystrcpy (string, "Hello world");strcat (string, "!");puts (string);


What is syntax of memcpy?

memcpy function is used to copy memory area. Syntax ------ void *memcpy(void *dest, const void *src, size_t n); *dest is a destination string. *src is a source string. n is a number of characters to be copied from source string. Example: #include #include main() { char src[]="Hello World"; char des[10]; memcpy(des,src,5); printf("des:%s\n",des); //It will contain the string "Hello". }


Geta is a math function or string function?

GetA is a math function and not a string function.


What are the function of dI and sI register?

The SI (Source Index) and DI (Destination Index) registers are useful in repeated string operations, such as copy. The DS (Data Segment) register is paired up with SI and the ES (Extra Segment) register is paired up with DI.


Which is string function starchy or strlength?

The string function is strlength and it is evoked to return the length of a string.


How do you write the concatenate the strings using pointer?

char* strcat (char* destination, const char* source) { char* return_value = destination; // temp destination for return while (*(destination++) != '\0'); // find end of initial destination while ((*(destination++) = *(source++)) != '\0'); // copy source to end of destination return return_value; // return original value of destination }


What are 4 string handling function?

strlen(s1) to find the length of the string s1 strcpy(s1,s2) copy source string to destination string(i.e copies s2 to s1,s2 remain unchanged) strcmp(s1,s2) compares s1 and s2 and prints 0 if s1 and s2 are equal,-1 if s2 is greater, 1 if s1 is greater strcat(s1,s2) combines string s1 and s2 to a single word and stores it in s1 strupr() converts lower case string to upper case strlwr() converts upper case string to lower case


How do you reverse a string in PHP without using a function?

Without any function is impossible. So I'll assume you mean any coded function, in which case the predefined function below is your answer.$string = strrev($string);


Which function joins two arrays of character in c language?

C provides the strcat() function, and its prototype is:char *strcat (char *destination, const char *source);destination must have enough memory allocated for itself and source. If you want to join two character arrays into a newly allocated string, use the following function:char *strcombine(char *str1, char *str2){/* size_t is a standard size or length integer type */size_t len;/* this is the pointer to the new string */char *returnstr;/* figure out the new string length */len=strlen(str1)+strlen(str2)+1;/* allocate memory for the return string and init to a length of 0 */returnstr=(char*)malloc(len);*returnstr=0;/* concatenate str1 and str2 to returnstr */strcat(returnstr, str1);strcat(returnstr, str2);/* return the new string */return returnstr;}Note that typecasting the malloc() return value as (char*) is just a formality under C; under C++, however, it's required to avoid warnings.Also, the above function does not test to see if str1and/or str2 are NULL values.


What function are used for string length in visual basic?

string length is a function use to check the lenght of a string i.e number of alphabets in a word or sentence.


Reverse of a string without using string handling function?

shashi


How string can be passed to a function in c?

between parentheses: funname ("string")