Affiliate Programs
 
Search affiliate programs for: 
Affiliate Categories
» Affiliate Networks
» Ad Networks
» 2 Tier Programs
» Pay Per Sale
» Pay Per Lead
» Residual Income
» Datafeeds
» Multi Tier Programs
» Business Opps
» Other Programs

Newsletter
Get newly added affiliate programs by email. Enter your email here:
Article Categories
» Affiliate Marketing
» Business
» Ecommerce
» Hosting
» Marketing
» Sales
» Web Designing
» Webmasters
» SEO & Promotion
» Working At Home
» Other Articles
» Affiliate Glossary


Go Back   AffiliateSeeking Forum > Website Creation, Design & Maintenance > Programming

Programming Get help with creating your scripts/software or help others. Discuss anything relating to programming. Includes PHP, Perl, C++, ColdFusion, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-06-2011, 03:00 PM
enter1234 enter1234 is offline
Senior Member
 
Join Date: Jun 2011
Posts: 152
enter1234 is on a distinguished road
Default File handling in C

File handling in C language- File pointers--

C language communicates with files using a new datatype called as a file pointer. Defined within its stdio.h(header file), and written as FILE*. pointer like output_file is declared in a statement like FILE*output_file;

Opening of File pointer using fopen

Code:
if ((output_file = fopen("output_file", "w")) == NULL)
fprintf(stderr, "Cannot open %s\n", "output_file");
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-23-2011, 05:34 PM
pullupbanner pullupbanner is offline
Senior Member
 
Join Date: Sep 2011
Posts: 306
pullupbanner is on a distinguished road
File Handling in c
A file is a collection of bytes stored on a secondary storage device, which is generally a disk of some kind. The collection of bytes may be interpreted, for example, as characetrs, words, lines, paragraphs and pages from a textual document; fields and records belonging to a database; or pixels from a graphical image. There are two kinds of files that programmers deal with text files and binary files.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-01-2011, 10:36 AM
jogan jogan is offline
Junior Member
 
Join Date: Nov 2011
Posts: 3
jogan is on a distinguished road
It was interesting to know that the C language indeed communicates with files. I think this file pointer, a new data type, has been very much helpful compared to the previous method that C language used. It is also good to learn how the file pointer can indeed be opened with this script.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-08-2011, 09:10 AM
Jewell90 Jewell90 is offline
Banned
 
Join Date: Oct 2011
Posts: 9
Jewell90 is on a distinguished road
file handling in C is different from C++ and is a bit awkward especially if you have missed the classes, funny how no one has realized you are talking about C.
File handling allows you store data in files that can be read - it is like when you have a spread sheet or a database you store the information on a seperate file. A file is simply a machine decipherable storage media where programs and data are stored for machine usage.Essentially there are two kinds of files that programmers deal with text files and binary files.
A text file can be a stream of characters that a computer can process sequentially. It is not only processed sequentially but only in forward direction. For this reason a text file is usually opened for only one kind of operation (reading, writing, or appending) at any given time.
A binary file is no different to a text file. It is a collection of bytes. In C a byte and a character are equivalent. So a binary file is also referred to as a character stream.
What you need to open a file in C is use a type called the file pointer this is found in the stdio header file so here is an example this will open a file called stuff.txt and write a line of text ten times.
FILE *fp; /* this is the file pointer */
char stuff[25];
int index;
fp = fopen("stuff.txt","w"); /* open for writing */
strcpy(stuff,"This is an example line.");
for (index = 1; index <= 10; index++)
/* this writes to the file the text */
fprintf(fp,"%s Line number %d
", stuff, index);
fclose(fp); /* close the file before exiting */
The type FILE is used for a file variable and is defined in the stdio.h file. It is used to define a file pointer for use in file operations. Before writing to a file, it must opened. What this really means is that the system must be told that the program is to write to a file and what the file name is. This is done with the fopen() function. The file pointer, fp in this case, points to the file and two arguments are required in the parentheses, the file name first, followed by the file type. the second parameter is the file attribute and can be any of three letters, r, w, or a, and must be lower case which are read, write and append.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:28 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0
© 2004-2011 AffiliateSeeking. All rights reserved.