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
fgetc()The function fgetc() is used to read the character from the file. It returns the character pointed by file pointer, if successful otherwise, returns EOF.Here is the syntax of fgetc() in C language, int fgetc(FILE *stream)Here is an example of fgetc() in C language, Let’s say we have “new.txt” file with the following content −0, hell!o 1, hello! 2, gfdtrhtrhrt 3, demoNow, let us see the example −Example#include #include void main() { FILE *f; char s; clrscr(); f=fopen("new.txt", "r"); while((s=fgetc(f))!=EOF) { printf("%c", s); } fclose(f); getch(); }Here is the ... Read More
Float is a wrapper class provided to wrap float primitive value.Let us create a Float object with float primitive.// float primitive float myFloat = 24.22f; // Float object Float obj1 = new Float(myFloat);Let us now create a Float object from string.Float obj2 = new Float("39.87");The following is an example that displays both the ways discussed above with output.Example Live Demoimport java.lang.*; public class Demo { public static void main(String args[]) { float myFloat = 24.22f; Float obj1 = new Float(myFloat); System.out.println(obj1); Float obj2 = new Float("39.87"); System.out.println(obj2); } }Output24.22 39.87
calloc()The function calloc() stands for contiguous location. It works similar to the malloc() but it allocate the multiple blocks of memory each of same size.Here is the syntax of calloc() in C language, void *calloc(size_t number, size_t size);Here, number − The number of elements of array to be allocated.size − Size of allocated memory in bytes.Here is an example of calloc() in C language, Example Live Demo#include #include int main() { int n = 4, i, *p, s = 0; p = (int*) calloc(n, sizeof(int)); if(p == NULL) { printf("Error! memory not allocated."); ... Read More
fseek()fseek() in C language is used to move file pointer to a specific position. Offset and stream are the destination of pointer, given in the function parameters. If successful, it returns zero, else non-zero value is returned.Here is the syntax of fseek() in C language, int fseek(FILE *stream, long int offset, int whence)Here are the parameters used in fseek(), stream − This is the pointer to identify the stream.offset − This is the number of bytes from the position.whence − This is the position from where offset is added.whence is specified by one of the following constants.SEEK_END − End of ... Read More
The function realloc is used to resize the memory block which is allocated by malloc or calloc before.Here is the syntax of realloc in C language, void *realloc(void *pointer, size_t size)Here, pointer − The pointer which is pointing the previously allocated memory block by malloc or calloc.size − The new size of memory block.Here is an example of realloc() in C language, Example Live Demo#include #include int main() { int n = 4, i, *p, s = 0; p = (int*) calloc(n, sizeof(int)); if(p == NULL) { printf("Error! memory not allocated."); ... Read More
The function fopen() opens the file pointed by pointer and read or write the file. In the write mode, “w” is used and in the read mode, “r” is used.When a file exists in the directory, it treats as a new empty file and override the content of file by new data.Here is the syntax of fopen() in C langauge, FILE *fopen(const char *filename, const char *access_mode)Here, filename − The name of file which is to be opened.acess_mode − The mode to access the file like read or write mode.Here is an example of fopen() in C language, Let’s say ... Read More
Here is an example to print contents of a file in C language, Let’s say we have “new.txt” file with the following content.0, hell!o 1, hello! 2, gfdtrhtrhrt 3, demoNow, let us see the example.Example#include #include void main() { FILE *f; char s; clrscr(); f=fopen("new.txt", "r"); while((s=fgetc(f))!=EOF) { printf("%c", s); } fclose(f); getch(); }Output0, hell!o 1, hello! 2, gfdtrhtrhrt 3, demoIn the above program, we have a text file “new.txt”. A file pointer is used to open and read the file. It is displaying the content of file.FILE *f; ... Read More
The function isblank() is used to check that the passed character is blank or not. It is basically a space character and it also considers tab character(\t). This function is declared in “ctype.h” header file in C language and “cctype”” header file in C++ language.Here is the syntax of isblank() in C++ language, int isblank(int char);Here is an example of isblank() in C++ language, Example Live Demo#include #include using namespace std; int main() { string s = "The space between words. "; int i = 0; int count = 0; while(s[i]) { ... Read More
The function iswblank() is used to check that the passed wide character is blank or not. It is basically a space character and it also considers tab character(\t). This function is declared in “ctype.h” header file in C language and “cctype”” header file in C++ language.Here is the syntax of isblank() in C++ language, int iswblank(wint_t char);Here is an example of iswblank() in C++ language, Example Live Demo#include #include using namespace std; int main() { wchar_t s[] = L"The space between words."; int i = 0; int count = 0; while(s[i]) { ... Read More