Found 34484 Articles for Programming

Structures in C

Samual Sam
Updated on 26-Jun-2020 07:50:01

832 Views

Structure is a user defined datatype. It is used to combine the different types of data into single type. It can have multiple members and structure variables. The keyword “struct” is used to define structures in C language. Structure members can be accessed by using dot(.) operator.Here is the syntax of structures in C language, struct structure_name {    member definition; } structure_variables;Here, structure_name − Any name given to the structure.member definition − Set of member variables.structure_variable − This is the object of structure.Here is an example of structures in C language, Example Live Demo#include #include struct Data { ... Read More

strcspn() in C

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

222 Views

The function strcspn() counts the number of characters before first match of characters in both strings. This is declared in “string.h” header file. It returns the number of characters of first string before the occurrence of first matched character.Here is the syntax of strcspn() in C language, size_t strcspn(const char *string1, const char *string2)Here, string1 − The first string which is to be scanned.string2 − The second string which is used to search the matching character in first string.Here is an example of strcspn() in C language, Example Live Demo#include #include int main() {    char str1[] = "Helloworld!";    char ... Read More

delete() operator in C++

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

348 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

Isprint() in C++

Samual Sam
Updated on 26-Jun-2020 07:42:01

57 Views

The function isprint() is predefined function and it checks that the passed characters are printable or not. It returns non-zero value, if successful otherwise, zero. This function is declared in “cctype” header file.Here is the syntax of isprint() in C++ language,int isprint(int character);Here,character − The character is to be checked.Here is an example of isprint() in C++ language,Example Live Demo#include #include using namespace std; int main() {    int val1 = 28;    int val2 = 's';    int val3 = '';    if(isprint(val1))    cout

delete() and free() in C++

Samual Sam
Updated on 26-Jun-2020 07:44:07

1K+ Views

delete()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

fgets() and gets() in C

Samual Sam
Updated on 26-Jun-2020 07:46:12

1K+ Views

fgets()The function fgets() is used to read the string till the new line character. It checks array bound and it is safe too.Here is the syntax of fgets() in C language, char *fgets(char *string, int value, FILE *stream)Here, string − This is a pointer to the array of char.value − The number of characters to be read.stream − This is a pointer to a file object.Here is an example of fgets() in C language, Example Live Demo#include #define FUNC 8 int main() {    char b[FUNC];    fgets(b, FUNC, stdin);    printf("The string is: %s", b);    return 0; }OutputThe ... Read More

size_t data type in C

Samual Sam
Updated on 26-Jun-2020 07:47:14

8K+ Views

The datatype size_t is unsigned integral type. It represents the size of any object in bytes and returned by sizeof operator. It is used for array indexing and counting. It can never be negative. The return type of strcspn, strlen functions is size_t.Here is the syntax of size_t in C language, const size_t var_name;Here, var_name − This the name of variable.Here is an example of size_t in C language, Example Live Demo#include #include #include int main(void) {    const size_t x = 150;    int a[x];    for (size_t i = 0;i < x; ++i)    a[i] = ... Read More

The Best C++ Code Formatter/Beautifier?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

633 Views

There are so many C++ code formatter or beautifier tools which beautifies your code or format with proper indentation. The C++ code formatter/ beautifier are listed as follows − C++ Code Formatter/Beautifier Description Astyle This is a source code formatter. It can be used for C++, java and other languages. It’s latest version is 2.03 and it released in April 2013. Clang-Format It is a command line tool along with clang compiler. It is open- source tool and programmed in C++, python. The latest version is 3.3. Universal Indent GUI It ... Read More

The Best C++ IDE or Editor for Windows

Samual Sam
Updated on 30-Jul-2019 22:30:23

218 Views

The following are some of C++ IDEs for Windows. 1.Eclipse Galileo with CDT Plugin Eclipse is a well-known open source and cross platform IDE. It provides full functional C/C++ IDE with the following features − Code editor with support for syntax highlighting Support for folding and hyperlink navigation Source code refactoring plus code generation Tools for visual debugging such as memory, registers 2.NetBeans NetBeans is free, open source and popular IDE for C/C++. There are some following features − Support for automatic packaging of compiled application into .tar, .zip. Support for multiple compilers such as GNU, Clang/LLVM, ... Read More

When to use i++ or ++i in C++?

Samual Sam
Updated on 26-Jun-2020 07:36:30

1K+ Views

Increment operators are used to increase the value by one while decrement works opposite. Decrement operator decrease the value by one.Pre-increment (++i) − Before assigning the value to a variable, the value is incremented by one.Post-increment (i++) − After assigning the value to a variable, the value is incremented.Here is the syntax of i++ and ++i in C++ language,++variable_name; // Pre-increment variable_name++; // Post-incrementHere,variable_name −Name of the variable given by user.Here is an example of pre and post increment in C++ language,Example Live Demo#include using namespace std; int main() {    int i = 5;    cout

Advertisements