• C

Just starting out easy points

I am just starting to learn to program just a little bit um i am trying to find out how to open files from the c promt but i can't and what is the best way to learn to program?
WhlGyroAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
avizitConnect With a Mentor Commented:
To open a file you have to use a editor

from a dos prompt  you can type "EDIT <filename>"

but believe me editing files in DOS is not a pleasant experience , you would be better off using one of those windows IDE for developing programs

for C programming you can use
Microsoft Visual C++
or free ones like devcpp  http://www.bloodshed.net/devcpp.html

/abhijit/



0
 
stefan73Connect With a Mentor Commented:
Hi WhlGyro,
If you want to do it the "real way" without the "point-and-click" fuss, download cygwin (http://www.cygwin.com) and gvim (http://www.vim.org/) and use gvim and gcc.

Cheers,
Stefan
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
ankuratvbCommented:
If you want to learn C programming,
Read Kernighan & Ritchie(k&r as it is called) The C programming Language

For opening files,i think the previous comments have covered a lot of options.
0
 
ankuratvbCommented:
>how to open files from the c promt

Do u want to know how to do this using C??

If that is the case,use fopen().

Pls post back for any clarifications.
0
 
unityxx311Commented:
Hi,

Like Stefan said I would grab cygwin if I was stuck with Windows so that I could use the gcc compiler. Then I would get a text editor. ViM is good, but I personally like GNU Emacs better. There is a binary version for Windows you can download and you can do just about everything within the editor.
http://www.gnu.org/software/emacs/emacs.html

Regards, m.
0
 
Avik DasguptaCommented:
>> how to open files from the c promt
for files which have text based information or text files, u have to use the MS-DOS text editor (to view file contents and editing). Likewise there are different classes of programs which open different classes of files. But all files can't be opened from DOS prompt which u are referring as the C prompt. Image or picture files can be opened by programs like Mspaint, Adobe Photoshop etc. Audio files like *.wav, *.mid, *.mp3 are opened by Windows Media Player, etc ...
Each special type of file has a header which has all the information about the file which is required by its appr program to open. u can even write a prog. to open an image file like *.bmp or *.jpeg , etc in C by incorporating its header structure. Anyway thats meaningless to do from DOS.
From C program u have to learn about the command line parameters and file operations to get an idea of how to write programs in C to open files . here is a small piece of code for u to understand the process of file openning.
// name the file as prog.c
#include<stdio.h>

int main(int argc,char *argv[])
{
 int c;
 FILE * fp; // this is the pointer to file structure
 /* argc is the number of arguments and argv is an array of          strings argv[0] being the prog name, argv[1] the first parameter and so on... */
 if((fp=fopen(argv[1],"r"))==NULL){ // file opened in read mode
    printf("cannot open file");return 1;}
 else{
    while((c=fgetc(fp))!=EOF){putc(c);} // put to terminal until EOF
    fclose(fp); // flush and unlink all buffers for fp
    return 0;
 }
}
compile and build this code
suppose u have a text file t.txt
c:\tcc>prog t.txt
will display ur file contents.

Avik.
0
 
stefan73Commented:
unityxx311,
> ViM is good, but I personally like GNU Emacs better
Aaah... An Emacs zealot.

Of course, Emacs is nice. It has to be, since it's a Unix tool. But apart from that...

Real men use vi in ex mode only :-)

Stefan
0
 
unityxx311Commented:
Hi,

Found a good introduction on both Vi and emacs.. very short but in one page gives you an idea of the differences. <@;)
http://www.doc.ic.ac.uk/~wjk/UnixIntro/Lecture6.html

m.
0
 
akshay_enviableCommented:
hi everybody!
yeah,command line parameters rule!opening a text file using command line parameters is pretty easy to learn.once u get the hang of it, u can do just about anything.
bye 4 now
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.