Question:
Can we write a C Program in Linux.... Pls help?
1970-01-01 00:00:00 UTC
Can we write a C Program in Linux.... Pls help?
Seven answers:
2011-08-02 07:22:17 UTC
What the "Linux" icon likely does is use "Dave's Telnet" program to automagically connect you to a separate Linux box.



If you want to run a Linux-style system under XP, and I can see because you're highly intelligent that this is what you wish to do, visit http://www.mingw.org/wiki/Getting_Started to download the Graphical Userface Installer. After you've run this, you'll have access to a command line interface, GCC compiler, vim and many of the regular Linux utilities. (No 'man' pages or stuff like that yet, so you're limited to Internet searches.)



You'll see references to "Cygwin". The downside to this environment is that Cygwin-produced executables depend upon a Cygwin library that you have to distribute with your executable, but it fully supports POSIX (a standard library). However, whereas MinGW programs don't depend upon a special library for programs to run, it does not fully support POSIX. At least that's from a quick search I did, since this information was already rusty. Try a Web search for "cygwin vs mingw msys" without the quotes for details, particularly: http://stackoverflow.com/questions/57627/msys-vs-cygwin



I'd also recommend familiarising yourself more with vim. Check out a Web search for "vim tutorial". It's a powerful text editor.



Never tried Linux mint. I used to run Slackware Linux, but that system died. So I stick to XP with the compiler suite noted above. Mint should already come with vim and gcc.



(Oh, here's a trick: try "gcc -o " and replace with a desired binary executable name. I.e. "gcc -o barfometer barf.c". No quotes, of course.)
?
2011-08-02 07:21:55 UTC
If you want to mimic your environment under Windows, get cygwin:



http://www.cygwin.com/



If you have the space, do a full install. The default install doesn't include gcc, so if you don't do a full one, you'll have to navigate the packages in the installer and turn it on. You can search for the vim package, too, and make sure it's set to install.



Then you can follow your same steps from the cygwin window (open window, launch vim, call gcc, run executable), or you can use a Windows-based editor to edit (look for notepad++, it does syntax highlighting for a lot of languages), and compile and run from the shell. I do this a lot when for simple command line programs when I don't want to run a full IDE.



Also, if you develop under cygwin and want to transfer it to your linux account, you can use scp to transfer files between the two:

scp USER@LINUXMACHINENAME:~/

You can also telnet and/or ssh to your school's host directly from the cygwin prompt (assuming you installed telnet and/or ssh packages).



Note: you can share SOURCE (.c files) between windows and linux, but not EXECUTABLES (a.out, or a.exe). You'll have to run gcc on the linux machine once you've transferred your source file.



If you open it on the linux machine and there's a bunch of ^M all over the file, don't panic - windows and unix treat carriage returns differently. Close the file, call "dos2unix ", and reopen it.



If you just want to do it all in linux from your mint install, scp, telnet, and ssh will work there as well. You just have to open a Terminal window to get started, most linux installs will have gcc and vim installed already. If they're not installed, just run a "sudo apt-get gcc" and "sudo apt-get vim" from the command line. It should ask for root password (unless you're logged in as root. Also, don't log in as root).



My preference is to live in Windows and use cygwin when I want to do "unix-y" things with gcc or awk and grep. You might end up preferring to run in Linux all the time, but I think cygwin is worth a try.
Anza Power
2011-08-02 06:44:55 UTC
That is not exactly a software, you are communicating with your Linux account using the Linux terminal (which is like the cmd for windows) all the work you are doing is communicating with another computer (which runs Linux) and you are writing and running the program on that computer...



If you wanna use Windows, I'd suggest a comfortable IDE program, like Eclipse or Visual Basic



Or you can install Ubuntu on your computer (it's free and can be installed without removing Windows XP) and work with it (Ubuntu is a Linux OS)
2014-09-30 06:42:21 UTC
Write a main program that performs the following steps:

Prompt the user to enter a string, and let them type it in. This could be an entire sentence, with the newline indicating the end of the string. You may assume the string will be no more than 100 characters, so declare your array accordingly.

Display the following menu:

A) Count the number of vowels in the string

B) Count the number of consonants in the string

C) Convert the string to uppercase

D) Convert the string to lowercase

E) Display the current string

F) Enter another string



M) Display this menu

X) Exit the program

Enter a loop, allowing the user to type in a menu choice each time. Loop should continue until the user enters the command to exit. Upper and lowercase letters should be allowed for the menu choices.

When the A or B commands are entered (counting vowels or consonants), call the corresponding function, then print the result

When the C or D commands are chosen, just call the appropriate function to convert the string. Do not do any output from main on these commands.

When E is chosen, print the contents of the stored string.

When F is chosen, allow a new string to be typed -- this will replace the previous one.

The menu should only be displayed once at the start, and then again whenever the M option is selected
Linux Mint 11
2011-08-02 11:46:58 UTC
How to Install C and C++ Compilers in Ubuntu and testing your first C and C++ Program (also applies to Linux Mint)

http://www.ubuntugeek.com/how-to-install-c-and-c-compilers-in-ubuntu-and-testing-your-first-c-and-c-program.html





LUg.
Matt
2011-08-02 07:28:24 UTC
You're basically doing everything on the server you're connecting to when you click on the "linux icon".



Boot back into Linux Mint, open the program to Install Software. Search and install "gcc". If it's already installed, open a Terminal. Then use the same steps.



vim file.c [Not sure, but you might need to install this], insert, :wq

then gcc file.c, then run it with ./a.out
Blackcompe
2011-08-02 07:18:03 UTC
Your using a Telnet client to connect to a Telnet server so that you can issue system commands to the remote server. Your school's CS servers are running VIM editor and GNU GCC and by using Telnet you can access them.



As for developing on your own machine, I'd highly suggest doing C development in a Linux environment, because installing GCC is simple, and as you pointed out above, compiling and executing programs is too. You can also download VIM easily. Open your terminal and type:



sudo apt-get install vim gcc glibc libstdc++ make gdb binutils



You have two options for installing standalone GCC on Windows: Cygwin and MinGW. I've never used MinGW, so I don't know how difficult the process is, but Cygwin isn't as easy to double-clicking an executable. The tutorial I linked below makes it very easy though. Cygwin provides a UNIX-like environment for C development and MinGW is native Windows.



Thokling presents a very good point. MinGW only depends on the Microsoft C runtime, whereas Cygwin uses a compatibility layer that emulates the POSIX API. So, you'll need Cygwin on any Windows machine that you distribute the binary to. Considering that binaries developed on different operating systems aren't compatible whatsoever (different file formats), MinGW is the way to go if you want to distribute binaries for Windows. If you needed to build source code developed in a UNIX environment, on a Windows machine, then you'd need Cygwin.



IDE's usually complicate things for beginning programmers. But, they are very powerful, most notably, in helping to correct syntax errors. Bloodshed C++ is very popular; it comes with MinGW. It's a simple Windows installer package. C++ is an extension to C, so gcc will compile C code. Another easy-to-setup IDE is Visual Studio C++. This is probably the most popular IDE, especially in college computing labs. It's very good.



If you do decide to go the Linux route and you want an IDE, I highly suggest CodeBlocks. And lastly, you can use Ideone -- an online IDE -- for quick development.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...