Main function parameter in C language

Main function parameter in C language

View Answers

December 4, 2009 at 1:01 PM

Hi Friend,

int main(int argc, char **argv)

The main function serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program. A program usually stops executing at the end of main, although it can terminate at other points in the program.The parameters argc, argument count, and argv, argument vector[1], respectively give the number and value of the program's command-line arguments.

The fgetpos function gets the current value of the stream argument?s file-position indicator and stores it in the object pointed to by pos. The fsetpos function can later use information stored in pos to reset the stream argument?s pointer to its position at the time fgetpos was called.


Here is an example of fsetpos();

#include <stdio.h>

int main (){
FILE * pFile;
fpos_t position;

pFile = fopen ("myfile.txt","w");
fgetpos (pFile, &position);
fputs ("That is an example of fsetpos() function",pFile);
fsetpos (pFile, &position);
fputs ("This",pFile);
fclose (pFile);
return 0;
}

Here is an example of fgetpos():

#include <stdio.h>
#include <conio.h>
int main ()
{
FILE * pFile;
int c;
int n;
fpos_t pos;

pFile = fopen ("myfile.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
c = fgetc (pFile);
printf ("1st character is %c\n",c);
fgetpos (pFile,&pos);
fsetpos (pFile,&pos);
c = fgetc (pFile);
printf ("2nd character is %c\n",c);

fclose (pFile);
}
getch();
return 0;

}
Thanks









Related Tutorials/Questions & Answers:
Main function parameter in C language - Ajax
Main function parameter in C language  Please let me know how...; Hi Friend, int main(int argc, char **argv) The main function serves... of fgetpos(): #include #include int main () { FILE * pFile; int c
C language-qsort and bsearch function - Ajax
C language-qsort and bsearch function  Explain qsort and bsearch function doing examples with character array.please also answer my previous question on main()parameters.thanks.  Hi Friend, bsearch function
Advertisements
C Language
C Language  What's the right declaration for main()? Is void main() correct? in C language ? please help me sir ! Thank You
bsearch() function in C
bsearch() function in C Programming Language This section demonstrates the use bsearch() function in C. This searches function the given key in the array... by b is greater than the a, it will return -1. In the main function, user
Understanding public static void main function
Understanding public static void main function       The public static void main function is important function in Java programming language. In this section we will learn about main
main function
main function  Give me the description of public static void main(Strings args
C Pointer to a function
; function in C. C provides a special feature of  pointer to a function. As you know  that every function defined in C language have a base address... C Pointer to a function   
C language
C language  i want that when i hit any key only * to be print not the hit key in c language   The given example will display aestricks... main() { char data[15]; /* max length 14 characters say */ int index
C Language
C Language  Respected sir, Why does sizeof report a larger size than I expect for a structure type, as if there were padding at the end? help me sir
C Language
C Language  Respected Sir, How can I determine the byte offset of a field within a structure? How can I access structure fields by name at run time? please help me sir . Thank you sir
Main function.. - Java Beginners
Main function..  Hi Friend.. public static void main(String args[]) What does it mean...public - static - void - main -(String args[]) Can u plz... return the value when it exits main(): This is the entry point for the application
c language code
c language code  Dear Sir, Could you send me the c language codings for BOOK BANK
example of function overriding in c++
example of function overriding in c++  require an example of function overriding in c
C/C++/JAVA Question on function
C/C++/JAVA Question on function  "Write a function to find out common... other data type also.ΓΆβ?¬Β? Question can be solved in C,C++ or JAVA. (Recommneded - C
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
c-language pointer functions
c-language pointer functions  what is the execution process of character pointer functions with example
Objective-C program with multiple parameter
Objective-C program with multiple parameter       Objective-C enables programmer to use method with multiple parameter. These parameter can be of same type or of different
main function defnition in class - Java Beginners
main function defnition in class  why do we use public infront of a main function   Hi friend, The main method is similar to the main function in C and C++; it's the entry point for your application
hotel management programme in c language?
hotel management programme in c language?  hotel management programme in c language
about a program in c language
about a program in c language   Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement
Function pointer in c
Function pointer in c  What is the difference between function call with function pointer and without function pointer(normal function call
C Language - Java Beginners
C Language  1. What are extension files? Give examples. 2. What is operating system? What are the different types available? 3. What is the purpose of operating system? 4. What is the function of operating system? 5
main function in java - Java Interview Questions
main function in java  1....why is function main() define as static in java? 2...drawbacks of using rmi
function overloading in c
function overloading in c  are int func1(int x, int y) and void func1(int x, int y) overloaded? can the functions with same name same arguments but different return types be overloaded
logic for c language
logic for c language  01 02 03 04 05 06 20 21 22 23 24 07 19 32 33 34 25 08 18 31 36 35 26 09 17 30 29 28 27 10 16 15 14 13 12 11
C file fsetpos() function
C file fsetpos() function This section demonstrates the use of fsetpos() function in C. The function fsetpos() is used to set the position of the stream... from the function fgetpos(). Its syntax is: fsetpos(File *stream,const fpos_t
Change case in C language
Change case in C language  I want to right in .dat file through structure.For this i have defined following: struct student //structure defination... If user is typing b5678 ,i want to store as B5678. (C)for input i am using
C file fseek() function
C file fseek() function This section demonstrates the use of fseek() function in C. This function sets the file position indicator for the stream pointed... with an example. In the following code, the function fopen(file, "w"
C++ programming language - Java Beginners
C++ programming language  int main() { int i = 1, c = 0, sum = 1,j ; scanf("%d", &j); while (i <= j) { sum = sum + (i /3+i/5); printf
c programming language - Java Beginners
c programming language  int main() { int i = 1, c = 0, sum = 1,j ; scanf("%d", &j); while (i <= j) { sum = sum + (i /3+i/5); printf("%d
java equivalent of c function htonl & htons
java equivalent of c function htonl & htons  hi is there any java equivalent for the c function htonl & htons
write a program to use for loop print **********========== in c language
write a program to use for loop print **********========== in c language  write a program to use for loop print **========== in c language
What is Public static void main
What is Public static void main In most of the Programming language, main function is the first function where program start execution. This is the first... are the variation of main method. public static void main(String[] args) public
<c: out> in JSTL
library tag is <c: out>. The main function of the this tag is to display...<c: out> in JSTL      ...;.  Attributes of the <c: out> core action tag.  value
Write a C language program to read two matrices and multiply them?
;stdio.h> #include <conio.h> int main() { int m, n, p, q, c, d, k, sum...Write a C language program to read two matrices and multiply them?  Write a C language program to read two matrices and multiply them?   
C Language - Design concepts & design patterns
C Language  What is meant by %u in printf statement in c? for example,%d means integer value,like that what is %u?  Hi Friend, %u is used to print an unsigned integer. Unsigned integers are non-negative numbers
<c: out> attribute default
core library tag is <c: out>. The main function of the this tag...<c: out> attribute default   ...;.  Attributes of the <c: out> core action tag.  value
How I call the function union from the main - Java Interview Questions
How I call the function union from the main  Please, from public static void main(String[] args) I would like to call the function union and I... declared in main function //------------------------------- package model
Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace in the label text. - Subversion
Request[/searchMenu] does not contain handler parameter named 'function'. This may be caused by whitespace in the label text.  Hi, i am using... not contain handler parameter named 'function'. This may be caused by whitespace
How ro convert char into string using recursive function in c#??
How ro convert char into string using recursive function in c#??  This coding is for java...but i want this in c# How ro convert char into string using recursive function in c#?? char [] ch={'H','E','L','L','o'}; TO ans
C file fgetpos() function
C file fgetpos() function This section demonstrates you the use of fgetpos() function. This function get the current read/write position of stream and stores...() function to return to the same position. Its syntax is: fgetpos(File *stream
<c: out> attribute escapeXml
library tag is <c: out>. The main function of the this tag is to display...<c: out> attribute escapeXml   ...;.  Attributes of the <c: out> core action tag.  value: It specify
Sample code for An ASCII Encryption and Decryption code in C-language only.
Sample code for An ASCII Encryption and Decryption code in C-language only... in ASCII format and only in C (NOT EVEN C++). Thank you.Please if possible post answers also to   #include<stdio.h> void main(){ FILE *fp1,*fp2
<c: out> For Simple Calculation and Output
purpose core library tag is <c: out>. The main function of the this tag...<c: out> For Simple Calculation and Output  ...;.  Attributes of the <c: out> core action tag.  value
c question
c question  How to convert decimal numbers into binary digits without using pow function in c language
Ask C/C++ Questions online
language, but both the languages are popular among programmers. C is a general purpose programming language that can run on most of the platforms. C is used... Bell Laboratory while C++ is a popular object oriented programming language
c++
c++  write a prgrm tht accepts 3 integer values,then with a function to swap the values

Ads