Solved

Just starting out easy points

Posted on 2004-04-14
12
229 Views
Last Modified: 2010-04-15
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?
0
Comment
Question by:WhlGyro
  • 2
  • 2
  • 2
  • +4
12 Comments
 
LVL 9

Accepted Solution

by:
Cayce earned 42 total points
ID: 10828629
0
 
LVL 11

Assisted Solution

by:avizit
avizit earned 42 total points
ID: 10829290
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
 
LVL 12

Assisted Solution

by:stefan73
stefan73 earned 41 total points
ID: 10830951
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
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10833940
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
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10833964
>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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Expert Comment

by:unityxx311
ID: 10835499
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
 
LVL 2

Expert Comment

by:Avik77
ID: 10836387
>> 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
 
LVL 12

Expert Comment

by:stefan73
ID: 10840471
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
 

Expert Comment

by:unityxx311
ID: 10842644
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
 

Expert Comment

by:akshay_enviable
ID: 11025499
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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now