1 777
Подписчики
-224 часа
-147 дней
-3630 день
Архив постов
1 777
Can you take a second to vote the poll to easy our notes and meets you well, which grade are you categorized in?
1 777
Error handling during file operations in C/C++
✅It is quite common that errors may occur while reading data from a file in C++ or writing data to a file.
Below are some Error handling functions during file operations in C/C++:
ferror():
❤️The ferror() function checks for any error in the stream. It returns a value zero if no error has occurred and a non-zero value if there is an error.
»sample code: https://t.me/learntocodecpp/454
clearerr():
🖤The function clearerr() is used to clear the end-of-file and error indicators for the stream.
»sample code: https://t.me/learntocodecpp/457
The function perror()
🤍stands for print error. In case of an error, the programmer can determine the type of error that has occurred using the perror() function.
»sample : https://t.me/learntocodecpp/4581 777
Error handling during file operations in C/C++
✅It is quite common that errors may occur while reading data from a file in C++ or writing data to a file.
Below are some Error handling functions during file operations in C/C++:
ferror():
❤️The ferror() function checks for any error in the stream. It returns a value zero if no error has occurred and a non-zero value if there is an error.
»sample code: https://t.me/learntocodecpp/454
1 777
Error handling during file operations in C/C++
🛑It is quite common that errors may occur while reading data from a file in C++ or writing data to a file.
Below are some Error handling functions during file operations in C/C++:
ferror():
🖤checks for any error in the stream. It returns a value zero if no error has occurred and a non-zero value if there is an error.
clearerr():
🤍is used to clear the end-of-file and error indicators for the stream.
perror():
❤️stands for print error. In case of an error, the programmer can determine the type of error that has occurred using the perror() function.
1 777
#include
using namespace std; main() { int a[] = {10, 20, 30}; cout<<*a+1; }
1 777
#include
using namespace std; main() { int i = 1, j = 2, k = 3, r; r = (i, j, k); cout<
1 777
Class is declared using the class keyword, and structure is declared using the struct keyword. //C++
1 777
Repost from Algo programmers
GENERICS IN C++
👉🏽Generics is the idea to allow type (Integer, String, … etc and user-defined types) to be a parameter to methods, classes and interfaces. For example, classes like an array, map, etc, which can be used using generics very efficiently.
✅Generics can be implemented in C++ using Templates. Template is a simple and yet very powerful tool in C++. The simple idea is to pass data type as a parameter so that we don’t need to write the same code for different data types.
For example let's look the program that sort() using the idea of generics:_
#include <iostream>
using namespace std;
// One function works for all data types.
// This would work even for user defined types
// if operator '>' is overloaded
template <typename T>
T myMax(T x, T y)
{
return (x > y) ? x : y;
}
int main()
{
// Call myMax for int
cout << myMax<int>(3, 7) << endl;
// call myMax for double
cout << myMax<double>(3.0, 7.0) << endl;
// call myMax for char
cout << myMax<char>('g', 'e') << endl;
return 0;
}
Уже доступно! Исследование Telegram 2025 — ключевые инсайты года 
