1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <Commdlg.h>
#include <Wtsapi32.h>
//FILE* fopen(const char* , const char* );
int WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int);
OPENFILENAME ofn ; //variable globale
char szFile[100] ;
void main(int argc, char *argv[])
{
char caractereActuel;
// L'ERREURE EST A LA LIGNE SUIVANTE !
WinMain (NULL, NULL, (LPWSTR) GetCommandLine(), 5); // L 17
FILE* fichier1 = NULL;
FILE* fichier2 = NULL;
fichier1 = fopen(szFile, "r");
fichier2 = fopen("data.txt", "w");
if (fichier1 != NULL)
{
caractereActuel = fgetc(fichier1); // On initialise caractereActuel
// Boucle de lecture des caractères un à un
while (caractereActuel != EOF) // On continue tant que fgetc n'a pas retourné EOF (fin de fichier)
{
printf("%c", caractereActuel); // On affiche le caractère stocké dans caractereActuel
if (caractereActuel ==' ') fputc('\t', fichier2);
else fputc(caractereActuel, fichier2);
caractereActuel = fgetc(fichier1); // On lit le caractère suivant
}
fclose(fichier1);
fclose(fichier2);
}
else
{
// On affiche un message d'erreur si on veut
printf("Impossible d'ouvrir le fichier Waveform.txt");
}
remove(szFile);
rename("data.txt", szFile);
}
int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nCmdShow )
{
// open a file name
ZeroMemory( &ofn , sizeof( ofn));
ofn.lStructSize = sizeof ( ofn );
ofn.hwndOwner = NULL ;
ofn.lpstrFile = szFile ;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof( szFile );
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex =1;
ofn.lpstrFileTitle = NULL ;
ofn.nMaxFileTitle = 0 ;
ofn.lpstrInitialDir=NULL ;
ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ;
GetOpenFileName( &ofn );
// Now simply display the file name
MessageBox ( NULL , ofn.lpstrFile , "File Name" , MB_OK);
return 0;
} |
Partager