写:
fprintf(hFile,ipbuff);
fprintf(hFile,"\n");
fprintf(hFile,portbuff);
ipbuff 和 portbuff 是输入的ip地址和端口;读:
         char ipbuff[16];
         char portbuff[6];
         Data = fopen("data.txt","r");  //这里没问题,文件名是硬编码的
fgets(ipbuff,15,Data);
         fgets(portbuff,5,Data);

解决方案 »

  1.   

    你在打开文件的时候没有加上MODEWRITE写
      

  2.   

    都不正确,建议好好看看MSDN吧
      

  3.   

    #include <stdio.h>
    #include <process.h>FILE *stream;void main( void )
    {
       int    i = 10;
       double fp = 1.5;
       char   s[] = "this is a string";
       char   c = '\n';   stream = fopen( "fprintf.out", "w" );
       fprintf( stream, "%s%c", s, c );
       fprintf( stream, "%d\n", i );
       fprintf( stream, "%f\n", fp );
       fclose( stream );
       system( "type fprintf.out" );
    }