亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

C語言

如何交換兩個(gè)文本內(nèi)容的C語言代碼

時(shí)間:2025-04-03 10:26:46 C語言 我要投稿
  • 相關(guān)推薦

如何交換兩個(gè)文本內(nèi)容的C語言代碼

  文本存儲(chǔ)的位置:

  jack.txt位于: e:jack.txt

  retchie.txt位于: e:retchie.txt

  內(nèi)容:

  jack.txt -> "Hello! I am Jack."

  retchie.txt -> "Hello! I am Retchie."

  相關(guān)代碼 代碼如下:

  #include

  int main(void)

  {

  char temp1[100];

  char temp2[100];

  FILE *p_jack;

  FILE *p_retchie;

  p_jack = fopen("e:/jack.txt", "r");

  p_retchie = fopen("e:/retchie.txt", "r");

  if (p_jack != NULL && p_retchie != NULL)

  {

  fgets(temp1, 20, p_jack);

  fgets(temp2, 20, p_retchie);

  }

  fclose(p_jack);

  fclose(p_retchie);

  p_jack = fopen("e:/jack.txt", "w");

  p_retchie = fopen("e:/retchie.txt", "w");

  if (p_jack != NULL && p_retchie != NULL)

  {

  fprintf(p_jack, "%s", temp2);

  fprintf(p_retchie, "%s", temp1);

  fclose(p_jack);

  fclose(p_retchie);

  }

  return 0;

  }

  運(yùn)行結(jié)果:

  內(nèi)容:

  jack.txt -> "Hello! I am Retchie."

  retchie.txt -> "Hello! I am Jack."

【如何交換兩個(gè)文本內(nèi)容的C語言代碼】相關(guān)文章:

如何優(yōu)化C代碼09-23

C語言精簡代碼10-03

如何提高單片機(jī)C語言代碼效率10-30

C語言的預(yù)處理代碼10-22

C語言快速排序?qū)嵗a10-30

C語言快速排序算法及代碼06-25

Java 語言與C 語言代碼運(yùn)行效率的比較11-01

C語言合并排序及實(shí)例代碼10-30

C語言兎子產(chǎn)子代碼07-30