TRENDING NEWS

POPULAR NEWS

Can Programme For Both C And C Run In The Same Compiler Mixed And Together

Do C programs run on linux?

First of all, the language you use and the operating system on which you run your code are two separate issues. Of course it is a good question whether or not a compiler for a particular language is available for a particular platform, but C being one of the most universal languages out there, this is certainly not a problem for common platforms. C was pretty much invented to write UNIX, the predecessor of Linux, and most of modern Windows is also written in C/C++, so yes, C compilers are available for both platforms.And if by "low level" programs, you mean (by way of example) a program that runs from the command line and doesn't do anything fancy with the hardware (no flashy graphics, no sound) then yes, it is eminently possible to write code either in pure C or C++ that can be compiled without change and run on both platforms.If you are doing something fancy (graphics, sound, etc.) things get a little complicated. But the reason for that is that such fancy things necessarily go beyond the language, relying instead on various special-purpose libraries supplied either as part of the compiler or the operating system. These libraries tend to be very different on different platforms, though you may be able to find a suitable cross-platform library that satisfies your requirements.Under (almost) no circumstances though will you be able to run the same executable file on both platforms. That is, your C/C++/etc. program, even if it needs no modification, needs to be recompiled for both platforms.Why "almost"? Many Windows programs can be run, on Linux, using the WINE (a self-referential acronym, Wine Is Not an Emulator) compatibility layer. With the help of WINE, you can run Windows executables (including programs with graphics and sound, and programs of your own creation) unmodified on Linux, without the need to recompile. WINE is not compatible with all Windows code, but it is surprisingly good, so simple programs of your own creation almost certainly would run.

Is the programming language C hard to learn?

If your ultimate goal is to learn C++ then you don't need to learn all of the concepts of C. But focus a lot on learning arrays, functions, and pointers, especially pointers before you try to learn C++

Difference between interpreter and compiler?

The fundamental distinction between the compiler and the interpreter is that compiler turns the program to machine code while interpreter scans the source code and executes it instead of producing a machine code.
In the compiled language the machine code is executed while in iterpreted languages the source code itself is executed with the help of interpreter i. e.
compiler + source code = machine code
execute machine code = output
interpreter + source code = output

Compilation of a program is one time method.
Once the program has been compiled the output file can be executed without having the need to compile it again and again. (as long as we do not need to change the program) For compiled languages the compiler creates the machine code which is understood by the machine.
Interpretation of language requires the interpreter to be present always when we require to execute the program.

Some examples:
Compiled languages: C, C++, Pascal
Interpreted Languages: GWBasic, Python, Perl

Therefore if we need to make a program in C then i would make my program in file test. c and compile it using the gcc compiler as
gcc test. c -o test
this would make an executable file test which I can execute as many times as I want. I can delete the compiler (gcc) and source file (test. c) and even then the executable test would execute (since it contains the machine code which can be understood by the machine).

If a make a program in perl I would execute my program test. pl using per interpreter (whose name is perl)as
perl test. pl
This would directly execute the program.

Write a console program?

Try this code (C++):
http://pastebin.com/us5LcJhA

edit: I sorted by the lowercase first dimension instead of the second... because otherwise it's retarded and not truly sorted.

MingW compiler and multithreading?

I am using Dev C++, which I believe uses the mingw compiler, and am following a windows api book.

I have just started the multithreading tutorial and the book suggests that some multithreading options need to be checked when using Microsoft visual c++.

After looking on google for the equivalent in dev c++, I am unsure about this topic:
-Do I need to specify -mthreads?
-Is it safe to use CreateThread?
-Can multithreading be done in dev c++?

If anyone has any experience actually programming multithreading in dev c++, that would be excellent

BC

Why is C called a compiled language?

Because we use a program called a “compiler” to translate C source code into machine language - which is then saved as a “.exe” file (or something similar). So whenever you run that C program, you’re really running pure machine language.Contrast that with an “interpreted” language such as JavaScript or Python in which the source code is read and it’s intent analysed and carried out by some other program immediately - without creating any machine language at all.In practice, there are half-way setups that use so-called “Just in time compilation” - where there is a compiler (of sorts) that compiles just one small piece of the source code at a time into machine language right before it needs to be executed. But such systems don’t usually keep that compiled code - and it gets thrown away at the end of the run.The approach C takes produces by far the fastest programs of the three. The downside is that while you’re developing your software, you have to wait for it to be compiled completely every time you make a change.The approach of doing an interpreter is that the moment you finish typing in a change, your program can start running immediately. This can save significant amounts of time while developing software - but the huge cost of running that interpreter all the time makes interpreted code run about 50 times slower than compiled code.Just-in-time compilation is intended to be the best of both worlds - and sometimes, it is. But for programs like computer games, where you need smoothly updating graphics and sound and such - it’s tough to tolerate the huge time sink that happens whenever your program hits a block of code that was never executed before during this run and has to be compiled all the way to machine code before it can be executed.So, languages like C and C++ are the fastest way to program a computer.Languages that use an interpreter are the slowest.Just-in-time approaches can make an interpreted language go faster - but produce really unpredictable time sinks - which can be disasterous for real-time or interactive programs.

Can I combine two programming languages in one practical project, e.g. C++ and C#?

Not in the same source file (though there are some exceptions where an extra language has been incorporated into another, e.g. Linq into C#, or assembly in C/Pascal). Seldom in the exact same project, but there are some examples (e.g. VB and C# is often mixed, as is Managed C++). Otherwise any form of linking to already compiled code (be that dynamic or static link) could easily be a situation where different parts of the program are written in different languages.Such techniques were often used to mix C, and Fortran and Pascal and ... Mixing Pascal, Fortran, and C with GCC, Mixing C++ with Other Languages. Using such ideas there's theoretically no limit to the languages you could incorporate into the same program.Further from that, what about programs with addon languages? These are usually not the same language the rest of the program was written in. E.g. Lua in a game developed in C++, that's usually used for stuff such as setting up which model to display when, the logic "AI" of sprites in the game, etc. While the C++ part works on the data and hardware actions. In this case you're even mixing compiled and interpreted.

Programming Languages: Is it possible to learn C and C++ at the same time or is this a bad idea?

Interesting.  A lot of the answers here so far diverge greatly from how I view C, C++ and the relationship therein.C came first and is widely regarded as the foundation of modern languages.  Many languages were influenced by C in some way or another and some "modern" languages still compile down/are written in C (e.g. Python).  In this way you could say that C is at a "low-level" while some other languages with more powerful abstractions are at a "high-level" (or "higher-level" as the case may be).  This observation being limited to the imperative programming space.C++ originally sought to extend the C languages, most notably by bringing Object Oriented concepts into the mix.  To put it in perspective, many (if not all) the first C++ compilers compiled C++ code to C code, so like a "modern" language like Python is at a "higher-level" than C, so too is C++.  While I think it might be conceptually understandable to say C++ is a "superset" of C, or that C++ is the next version of C, I don't think it is technically correct and can lead to confusion down the line.And contrary to most other answers here thus far, I would suggest learning C, not C++ first...and I may even suggest not learning C++ at all.This shouldn't be confused with calling C++ a bad language.  It's just that I think now, there are many other higher-level languages which have advantages over C++ now-a-days.As an illustration, take some of Linus Torvalds thoughts about C++:RFC Convert builin mailinfo.c to use The Better String Library. Gmane Loom And while I tend to personally agree with Linus on this and he is a man I hold in high technical regard, do keep in mind this is still an opinion.Bottom line, I would choose to learn C and then move on to a higher-level imperative language, of which there are many choices I think better than C++ (in no particular order):JavaScalaPython...And if you really wanted to try and get out in front of the industry and learn something that may become the "latest and greatest" trend, I would take a long hard look at Haskell and functional programming.

TRENDING NEWS