zoukankan      html  css  js  c++  java
  • convert.cpp

    代码
    // convert.cpp : 定义控制台应用程序的入口点。
    //

    #include 
    "stdafx.h"
    #include 
    <stdlib.h>
    #include 
    <string.h>

    int _tmain(int argc, _TCHAR* argv[])
    {
     FILE   
    *fp1;   //文件指针
     FILE   *fp2;   
     
    char buf[1024];//缓冲区 
     if(NULL == (fp1 = fopen("utf8.tab","r")))
     {
      exit(
    -1);
     }
     
    else
     {
      
    char *p1;
      unsigned 
    short d1;
      unsigned 
    long d2;
      
    char ch;

      
    if(NULL == (fp2 = fopen("txt.txt","w+")))
      {
       printf(
    "打开文件失败\n");
       exit(
    -1);
      }

      
    while(1)
      {
       
    if(NULL == fgets(buf,sizeof(buf)-1,fp1)) 
        
    break;
       p1
    =buf;
       memcpy(
    &d1,buf,2);
       
    if(6 == strlen(p1))
       {
        memcpy(
    &d2,buf+2,3);
       }
       
    if(5 == strlen(p1))
       { 
        memcpy(
    &d2,buf+2,2); 
       }
       fwrite(
    &d1,2,1,fp2);
       fwrite(
    &d2,3,1,fp2);
      }
      fclose(fp2);
     }
     
    return 0;
    }

     
  • 相关阅读:
    2017年第八届蓝桥杯C/C++ C组国赛 —— 第一题:哥德巴赫分解
    Tree Walk Aizu
    Tree Walk Aizu
    Binary Trees Aizu
    有效的括号
    划分整数
    最大子矩阵和
    最大子段和
    最长上升子序列
    合唱队形
  • 原文地址:https://www.cnblogs.com/kakaliush/p/1624763.html
Copyright © 2011-2022 走看看