Friday, September 16, 2016

C file I/O functions

C file I/O functions

    logic how to detect end of file:

  1. (stdio.h) library details can be found here::
  2. (math.h)library details can be found here::
  3. (cstring.h library )function memset
  4. function feof():: it contains goood library and function information. good reference
    /* feof example: byte counter */
    #include <stdio.h>
    int main ()
      FILE * pFile;
      int n = 0;
      pFile = fopen ("myfile.txt","rb");
      if (pFile==NULL) perror ("Error opening file");
        while (fgetc(pFile) != EOF) {
        if (feof(pFile)) {
          puts ("End-of-File reached.");
          printf ("Total number of bytes read: %d\n", n);
        else puts ("End-of-File was not reached.");
        fclose (pFile);
      return 0;
  5. EOF, getc() and feof() in C
    #include <stdio.h>
    int main()
      FILE *fp = fopen("test.txt", "r");
      int ch = getc(fp);
      while (ch != EOF) 
        /* display contents of file on screen */
        ch = getc(fp);
      if (feof(fp))
         printf("\n End of file reached.");
         printf("\n Something went wrong.");
      return 0;
  6. Detecting EOF in C
  7. Checking if the file pointer has reached EOF without moving the file pointer?
  8. How to use EOF to run through a text file in C?
  9. End of File (EOF) in C
  10. the following section is about file I/O related functions.

  11. C scanf()
  12. C printf()
  13. C – printf and scanf
  14. C Programming Examples on File Handling
  15. File Handling in C Language:: good examples

    an example to write to a file from std input and display the file::

     FILE *fp;
     char ch;
     fp = fopen("one.txt", "w");
     printf("Enter data");
     while( (ch = getchar()) != EOF) {
     fp = fopen("one.txt", "r");
     while( (ch = getc(fp)! = EOF)

    another example::

    /* read and write to file */
    struct emp
       char name[10];
       int age;
    void main()
       struct emp e;
       FILE *p,*q;
       p = fopen("one.txt", "a");
       q = fopen("one.txt", "r");
       printf("Enter Name and Age");
       scanf("%s %d",, &e.age);
       fprintf(p,"%s %d",, e.age);
          fscanf(q,"%s %d",, e.age);
          printf("%s %d",, e.age);
       while( !feof(q) );
  16. File Handling in C with Examples (fopen, fread, fwrite, fseek)
  17. File Handling in C Language
  18. Detecting EOF in C
  19. How to use EOF to run through a text file in C?

JQuery application in ASP.NET and configuration

Saturday, September 10, 2016

Converting C source to C++

convert c project to c++

  1. Refactoring: Convert C to C++

    this is the first paper to review.

  2. Case Study: Converting C Programs to C++
  3. Converting C source to C++
  4. Differences between C and C++
  5. Converting a C or C++ nature for a project
  6. how to convert c to c++ code
  7. C to C++ converter
  8. Compiling C in Visual Studio.NET

    Go to View Menu select Solution Explorer or CTRL+ ALT +L
    Then Select The project that your are developing and right click on that.
    Then select the Properties from the submenu.
    Then select the Configuration properties from the Tree structure. under that select C/C++ then select Advanced. Now in the right side pane change the property Compile As from Compile as C++ Code (/TP) to Compile as C Code (/TC)
    Finally change your file extensions to .c
    Now you configured you Visual Studio to compile C programs

List topics