Found 7197 Articles for C++

memcpy() function in C/C++

Samual Sam
Updated on 26-Jun-2020 08:08:37

6K+ Views

The function memcpy() is used to copy a memory block from one location to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language. It does not check overflow.Here is the syntax of memcpy() in C language, void *memcpy(void *dest_str, const void *src_str, size_t number)Here, dest_str − Pointer to the destination array.src_str − Pointer to the source array.number − The number of bytes to be copied from source to destination.Here is an example of memcpy() in C language, Example Live Demo#include #include int main () {   ... Read More

memmove() function in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 08:09:03

599 Views

The function memmove() is used to move the whole memory block from one position to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language.Here is the syntax of memmove() in C language, void *memmove(void *dest_str, const void *src_str, size_t number)Here, dest_str − Pointer to the destination array.src_str − Pointer to the source array.number − The number of bytes to be copied from source to destination.Here is an example of memmove() in C language, Example Live Demo#include #include int main () {    char a[] = "Firststring"; ... Read More

How can I convert string to double in C/C++?

Tapas Kumar Ghosh
Updated on 22-Apr-2025 18:26:45

1K+ Views

Given a string like "-27.89", we can convert it into a double value such as -27.890000. In this article, we use various approaches from C/C++ library functions to perform this string into double conversion: Using atof() Function Using strtod() Function Using stod() Function Using stringstream() Function String to Double Conversion Using atof() Function You can use atof() function of C library that accepts the parameter of string value to convert the string into a double. Example In this example, we illustrate atof() to convert string into double. #include #include int main() { ... Read More

strtod() function in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 08:10:10

411 Views

The function strtod() is used to convert the string to a floating point number. The string is converted into double type number. It returns the converted number, if successful otherwise, zero. This is declared in “stdlib.h” header file.Here is the syntax of strtod() in C language, double strtod(const char *string, char **endpointer);Here, string − The string to be converted.endpointer − The pointer of already allocated object and its value is set to the next character by the function after the numeric value.Here is an example of strtod() in C language, Example Live Demo#include #include int main () {   ... Read More

isgreaterequal() in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 08:03:19

278 Views

The function isgreaterequal() is used to check that the first argument is greater than or equal to the second one. It is declared in “math.h” header file in C language. It returns true on success, otherwise false.Here is the syntax of islessgreater() in C++ language, bool isgreaterequal(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 that is greater or equal.Here is an example of isgreaterequal() in C++ language, Example Live Demo#include #include using namespace std; int main() {    int val1 = ... Read More

strchr() function in C/C++

Samual Sam
Updated on 26-Jun-2020 08:03:47

376 Views

The function strchr() is used to search the character in the string. It search the first occurrence of character which is passed as second argument and it returns a pointer to the character, if successful otherwise, NULL.Here is the syntax of strchr() in C language, char *strchr(const char *string , int character)Here, string − The string which is to be scanned to search the character.character − The character which is to be searched in the string.Here is an example of strchr() in C language, Example Live Demo#include #include int main() {    char s[] = "Helloworld!";    char c = 'o'; ... Read More

strxfrm() in C/C++

karthikeya Boyini
Updated on 26-Jun-2020 07:51:52

353 Views

The function strxfrm() transforms the source string to the current locale and copies the first number of characters of transformed string to the destination. It is declared in “locale.h” header file in C language.Here is the syntax of strxfrm() in C language, size_t strxfrm(char *destination, const char *source, size_t number)Here, destination − The destination pointer where the characters will be copied.source − The string is to be transformed.number − The number of characters to be copied.Here is an example of strxfrm() in C language, Example#include #include int main () has {    char s[10] = "HelloWorld";    char ... Read More

islessequal() in C/C++

Samual Sam
Updated on 26-Jun-2020 07:52:25

259 Views

The function islessequalr() is used to check that first argument is less than or equal to the second. It is declared in “math.h” header file. It returns true, if successful otherwise false.Here is the syntax of islessequal()bool islessequal(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 that is less or equal.Here is an example of islessequal()Example Live Demo#include #include using namespace std; int main() {    int val1 = 8;    int val2 = 8;    bool result;    result = islessequal(val1, ... Read More

iswpunct() function in C/C++

Samual Sam
Updated on 26-Jun-2020 07:53:21

187 Views

The function iswpunct() is used to check that the passing wide character is a punctuation or not. It returns zero, if it is not a punctuation, otherwise it returns a non-zero value. It is declared in “cwctype” header file.Here is the syntax of iswpunct()int iswpunct(wint_t character);Here is an example of iswpunct()Example#include #include using namespace std; int main() {    wint_t a = '!';    wint_t b = 'a';    if(iswpunct(a))    printf("The character is a punctuation.");    else    printf("The character is not a punctuation.");    if(iswpunct(b))    printf("The character is a punctuation.");    else    printf("The character is not ... Read More

delete() operator in C++

karthikeya Boyini
Updated on 26-Jun-2020 07:54:39

500 Views

The delete operator is used to deallocate the memory. User has privilege to deallocate the created pointer variable by this delete operator.Here is the syntax of delete operator in C++ language,delete pointer_variable;Here is the syntax to delete the block of allocated memory,delete[ ] pointer_variable;Here is an example of delete operator in C++ language,Example Live Demo#include using namespace std; int main () {    int *ptr1 = NULL;    ptr1 = new int;    float *ptr2 = new float(299.121);    int *ptr3 = new int[28];    *ptr1 = 28;    cout

Advertisements