Click here to Skip to main content
16,005,473 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to open Dialog for choose folder Pin
tanvon malik24-Sep-06 6:22
tanvon malik24-Sep-06 6:22 
AnswerRe: How to open Dialog for choose folder Pin
tanvon malik24-Sep-06 6:36
tanvon malik24-Sep-06 6:36 
AnswerRe: How to open Dialog for choose folder Pin
Hamid_RT26-Sep-06 6:31
Hamid_RT26-Sep-06 6:31 
QuestionADO Recordsets and VC++ Pin
eusto24-Sep-06 5:08
eusto24-Sep-06 5:08 
QuestionFile input/output help Pin
eric_tran24-Sep-06 2:50
eric_tran24-Sep-06 2:50 
AnswerRe: File input/output help Pin
Eytukan24-Sep-06 3:16
Eytukan24-Sep-06 3:16 
AnswerRe: File input/output help Pin
singersinger24-Sep-06 3:22
singersinger24-Sep-06 3:22 
AnswerRe: File input/output help Pin
eric_tran24-Sep-06 4:20
eric_tran24-Sep-06 4:20 
Thanks very much.
Here is the code I've just done, but I can't display the right format

Please give me a fix.

#include <stdio.h>

void display(){	
  FILE *file1;
  int numbers[30]; 
  /* make sure it is large enough to hold all the data! */
  int i,j;
  //////////////////////
  file1 = fopen("try.txt", "r");

  if(file1==NULL) {
    printf("Error: can't open file.\n");   
  }
  else {
    printf("File opened successfully.\n");

    i = 0 ;    

    while(!feof(file1)) { 
      /* loop through and store into the array */
      fscanf(file1, "%s", numbers[i]);
      i++;
    }

    printf("Number of character read: %d\n\n", i);
    printf("The message are:\n");

    for(j=0 ; j<i ; j++) { /* now print them out 1 by 1 */
      printf("%s\n", &numbers[j]);
    }   
  }
}

int main() {
  
  FILE *file;      /* FILE pointer */
  char *array = "eric";
  
  //////////////////////
  file = fopen("try.txt", "w"); /* create a file for writing */

  if(file==NULL) {
    printf("An error has occurred.\n");
    return 1;
  }    

  /* now loop through the array and print  
     the data into a text file pointed to by file */
 
    fprintf(file, "%s\n", array);   
    
  display();

  fclose(file); /* now close the file */  
  
  return 0;
}




eric

GeneralRe: File input/output help Pin
eusto24-Sep-06 5:17
eusto24-Sep-06 5:17 
GeneralRe: File input/output help Pin
eric_tran24-Sep-06 5:26
eric_tran24-Sep-06 5:26 
GeneralRe: File input/output help Pin
eusto24-Sep-06 6:06
eusto24-Sep-06 6:06 
QuestionAccess violation problem Pin
singersinger24-Sep-06 2:44
singersinger24-Sep-06 2:44 
QuestionRe: Access violation problem Pin
Eytukan24-Sep-06 3:34
Eytukan24-Sep-06 3:34 
AnswerRe: Access violation problem Pin
Eytukan24-Sep-06 3:41
Eytukan24-Sep-06 3:41 
AnswerRe: Access violation problem Pin
Jörgen Sigvardsson24-Sep-06 14:32
Jörgen Sigvardsson24-Sep-06 14:32 
GeneralRe: Access violation problem Pin
singersinger24-Sep-06 21:46
singersinger24-Sep-06 21:46 
GeneralRe: Access violation problem Pin
Eytukan24-Sep-06 23:13
Eytukan24-Sep-06 23:13 
AnswerRe: Access violation problem Pin
Hamid_RT24-Sep-06 18:07
Hamid_RT24-Sep-06 18:07 
GeneralRe: Access violation problem Pin
Eytukan24-Sep-06 18:35
Eytukan24-Sep-06 18:35 
GeneralRe: Access violation problem Pin
Hamid_RT24-Sep-06 22:16
Hamid_RT24-Sep-06 22:16 
GeneralRe: Access violation problem Pin
Eytukan24-Sep-06 23:07
Eytukan24-Sep-06 23:07 
GeneralRe: Access violation problem Pin
Hamid_RT24-Sep-06 23:32
Hamid_RT24-Sep-06 23:32 
AnswerRe: Access violation problem Pin
singersinger24-Sep-06 22:37
singersinger24-Sep-06 22:37 
Questionusing Visual Studio to build C/C++ projects with dependencies Pin
George_George24-Sep-06 2:32
George_George24-Sep-06 2:32 
AnswerRe: using Visual Studio to build C/C++ projects with dependencies Pin
Eytukan24-Sep-06 3:23
Eytukan24-Sep-06 3:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.