Can any one help me me? need a c program to open a file using c

  • Thread starter Thread starter anbhu28
  • Start date Start date
  • Tags Tags
    File Program
AI Thread Summary
To open a file in C, the function "fopen" is used, where the first argument is the filename and the second is the mode (e.g., "r" for read, "w" for write). After opening a file, a pointer is returned that can be utilized for reading or writing operations. For reading file contents, functions like "fgets" or "fscanf" can be employed based on the desired format. Resources such as programming books and online tutorials provide sample codes and further explanations on file I/O in C. Understanding these functions is essential for effective file handling in C programming.
anbhu28
Messages
1
Reaction score
0
can anyone help me me? need a c program to open a file using c

pls can anyone send me a c programing code for opening a files
 
Technology news on Phys.org
anbhu28 said:
pls can anyone send me a c programing code for opening a files
Any books talk about c language will give you a sample code to do file IO. Also, you can get too many results by Google
http://www.cprogramming.com/tutorial/cfileio.html
http://www.cs.bu.edu/teaching/c/file-io/intro/
...
 


The simplest way to open a file is "fopen(Filename, mode)" where Filename is the file name as a string and mode is string such as "r" for "read only", "w" for "write", "a" for "append" (add to end of file), and a number of others.
That returns a pointer to the open file that you would then use in reading or writing to the file.

For example,
FILE *f= fopen("myFile","r");

makes f a pointer that can be used to read from "myFile".

You could then use "fread(buffer, 10,10, f)" to read up to 10 bytes from the file to the variable "buffer" (which you would declare as a pointer to the correct type of variable) or you could use fscanf(f, ...) to read a formatted string just as you would with "scanf".
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top