Found 1452 Articles for C

How to debug a core in C/C++?

Ankith Reddy
Updated on 24-Jun-2020 06:17:58

302 Views

A process dumps core when it is terminated by the operating system due to a fault in the program. The most typical reason this occurs is that the program accessed an invalid pointer value like NULL or some value out of its memory area. As part of that process, the operating system tries to write our information to a file to allow us to analyze what happened.This core can be used as follows to diagnose and debug our program −The core is dumped to the /proc/sys/kernel directory by default. To debug a core, the program must be compiled with the ... Read More

How can I get the list of files in a directory using C/C++?

Chandu yadav
Updated on 27-Jan-2020 12:32:32

2K+ Views

Standard C++ doesn't provide a way to do this. You could use the system command to initialize the ls command as follows −Example#include int main () {    char command[50] = "ls -l";    system(command);    return 0; }OutputThis will give the output −-rwxrwxrwx 1 root root  9728 Feb 25 20:51 a.out -rwxrwxrwx 1 root root   131 Feb 25 20:44 hello.cpp -rwxrwxrwx 1 root root   243 Sep  7 13:09 hello.py -rwxrwxrwx 1 root root 33198 Jan  7 11:42 hello.o drwxrwxrwx 0 root root   512 Oct  1 21:40 hydeout -rwxrwxrwx 1 root root    42 Oct 21 11:29 ... Read More

Why can't variables be declared in a switch statement in C/C++?

George John
Updated on 27-Jan-2020 12:30:17

689 Views

Variables can be declared in a switch statement. You'll just need to declare them and use them within a new scope in the switch statement. For example,Example#include using namespace std; int main() {    int i = 10;    switch(i) {       case 2:       //some code       break;       case 10:{          int x = 13;          cout

What does int argc, char *argv[] mean in C/C++?

Chandu yadav
Updated on 24-Jun-2020 06:12:03

6K+ Views

argc stands for argument count and argv stands for argument values. These are variables passed to the main function when it starts executing. When we run a program we can give arguments to that program like −$ ./a.out helloExampleHere hello is an argument to the executable. This can be accessed in your program. For example,#include using namespace std; int main(int argc, char** argv) {    cout

Why do we use extern "C" in C++ code?

Priya Pallavi
Updated on 30-Jul-2019 22:30:22

1K+ Views

You need to use extern "C" in C++ when declaring a function that was implemented/compiled in C.Using extern "C" lets the compiler know that we want to use C naming and calling conventions. This causes the compiler to sort of entering C mode inside our C++ code. This is needed because C++ compilers mangle the names in their symbol table differently than C compilers and hence behave differently than C compilers.

Is C++0x Compatible with C?

Srinivas Gorla
Updated on 30-Jul-2019 22:30:22

88 Views

Neither C++ (98) nor the new standard(C++0x or C++11) is fully compatible with C. C++ never was fully compatible with C.

How can I write in order with for loop or while loop?

Arnab Chakraborty
Updated on 20-Jun-2020 15:34:17

140 Views

Example#include #include void main() {    int i,j,a=0,b=1,n;    clrscr();    printf("****************OUTPUT*****************");    printf("enter the value of n : ");    scanf("%d",&n);    printf(" the required order is: " );    for(i=1;i

How do I set up C/C++ on Eclipse in Windows?

Arushi
Updated on 26-Feb-2020 11:21:22

8K+ Views

Step 1 − Install MinGW GCC or Cygwin GCCTo use Eclipse for C/C++ programming, you need a C/C++ compiler. On Windows, you could install either MinGW GCC or Cygwin GCC. Choose MinGW if you are not sure, because MinGW is lighter and easier to install, but has fewer features.MinGW GCCTo install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program which should be named MinGW .exe.While installing MinGW, at a minimum, you must install gcc-core, gcc-g++, binutils, and the MinGW runtime, but you may ... Read More

When to use C over C++, and C++ over C?

Kumar Varma
Updated on 18-Jun-2020 13:05:03

1K+ Views

If you would like an application that works directly with computer hardware or deals with the desktop app development, C++ is an good option. C++ programs include server-side applications, networking, gaming, and even device drivers for your PC. However, if you need to code truly tiny systems, using C will result in less overhead than C++.C++ is well-rounded in terms of platforms and target applications, so if your project is focused on extremely low-level processing, then you may want to use C++. C++ is often used for large-scale, multi-man, complex projects where separate people need to work on modularised components. ... Read More

What is the difference Between C and C++?

Alankritha Ammu
Updated on 10-Feb-2020 11:19:15

779 Views

Following are some of the differences between C and C++.When compared to C++, C is a subset of C++. All valid C programs are valid C++ programs.C is a structural or procedural programming language, while C++ is an object oriented programming language.In C, Functions are the fundamental building blocks, while in C++, Objects are the fundamental building blocks.C doesn't have variable references, while C++ has variable references.C uses malloc and free for memory allocation while C++ uses new and delete for memory allocation.C does not provide direct support for error handling, while C++ supports exception handling that helps in error ... Read More

Advertisements