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");
      else
      {
        while (fgetc(pFile) != EOF) {
          ++n;
        }
        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 */
        putchar(ch); 
     
        ch = getc(fp);
      }
       
      if (feof(fp))
         printf("\n End of file reached.");
      else
         printf("\n Something went wrong.");
      fclose(fp);
         
      getchar();
      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::

    #include<stdio.h>
    #include<conio.h>
    main()
    {
     FILE *fp;
     char ch;
     fp = fopen("one.txt", "w");
     printf("Enter data");
     while( (ch = getchar()) != EOF) {
        putc(ch,fp);
     }
     fclose(fp);
     fp = fopen("one.txt", "r");
     
     while( (ch = getc(fp)! = EOF)
        printf("%c",ch);
        
     fclose(fp);
    }
    

    another example::

    /* read and write to file */
    #include<stdio.h>
    #include<conio.h>
    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.name, &e.age);
       fprintf(p,"%s %d", e.name, e.age);
       fclose(p);
       do
       {
          fscanf(q,"%s %d", e.name, e.age);
          printf("%s %d", e.name, e.age);
       }
       while( !feof(q) );
       getch();
    }
    
  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?

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");
      else
      {
        while (fgetc(pFile) != EOF) {
          ++n;
        }
        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 */
        putchar(ch); 
     
        ch = getc(fp);
      }
       
      if (feof(fp))
         printf("\n End of file reached.");
      else
         printf("\n Something went wrong.");
      fclose(fp);
         
      getchar();
      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::

    #include<stdio.h>
    #include<conio.h>
    main()
    {
     FILE *fp;
     char ch;
     fp = fopen("one.txt", "w");
     printf("Enter data");
     while( (ch = getchar()) != EOF) {
        putc(ch,fp);
     }
     fclose(fp);
     fp = fopen("one.txt", "r");
     
     while( (ch = getc(fp)! = EOF)
        printf("%c",ch);
        
     fclose(fp);
    }
    

    another example::

    /* read and write to file */
    #include<stdio.h>
    #include<conio.h>
    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.name, &e.age);
       fprintf(p,"%s %d", e.name, e.age);
       fclose(p);
       do
       {
          fscanf(q,"%s %d", e.name, e.age);
          printf("%s %d", e.name, e.age);
       }
       while( !feof(q) );
       getch();
    }
    
  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