私は HW の課題で立ち往生しており、英語の単語の束 (入力 .txt ファイルの改行で区切られたリスト内) をピッグ ラテン語の単語の束 (リストに) に変換するプログラムを作成する必要があります。出力 .txt ファイルでは改行で区切られています)。私は本当に近づいてきましたが、strncat私が使用している関数(文字列連結)関数はどういうわけか新しい行を投げていますstdout。なぜこれが起こっているのでしょうか?これが私のコードです:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STR_SIZE 100
char * convertToPigLatin (char * strPtr, char * pLatinStr);
int main(int argc, char *argv[])
{
   char str[MAX_STR_SIZE];
   char pStr[MAX_STR_SIZE];
   //char *pStrPtr; 
   FILE *fileInPtr;                                     //Create file name
   FILE *fileOutPtr;    
   fileInPtr = fopen("pigLatinIn.txt", "r");    //Assign text to file
   fileOutPtr = fopen("pigLatinOut.txt", "w");
   //pStrPtr = pStr; 
   if(fileInPtr == NULL)                                //Check if file exists
   {
      printf("Failed");
      exit(-1); 
   }
   do                   //Cycles until end of text
   {
      fgets(str, 29, fileInPtr);                //Assigns word to *char
      str[29] = '\0';                           //Optional: Whole line
      convertToPigLatin(str, pStr); 
      fprintf(fileOutPtr, "%s", pStr); 
   }  while(!feof(fileInPtr));   
   system("pause"); 
}
char * convertToPigLatin (const char * strPtr, char * pStrPtr)
{
   int VowelDetect = 0; 
   int LoopCounter = 0; 
   int consonantCounter = 0; 
   char pStr[MAX_STR_SIZE] = {'\0'};
   char cStr[MAX_STR_SIZE] = {'\0'};
   char dStr[] = {'-','\0'}; 
   char ayStr[] = {'a','y','\0'};
   char wayStr[] = {'w','a','y','\0'};
   pStrPtr = pStr; 
   while (*strPtr != '\0')
   {
      if (*strPtr == 'a' || *strPtr == 'e' || *strPtr == 'i' || *strPtr == 'o' || *strPtr == 'u' || VowelDetect ==1)
      {
         strncat(pStr, strPtr, 1); 
         VowelDetect = 1; 
      }
      else
      {
         strncat(cStr, strPtr, 1); 
         consonantCounter++; 
      }
      *strPtr++;
   }
   strcat(pStr, dStr); 
   if (consonantCounter == 0)  
   {
      strcat(pStr, wayStr);
   }
   else
   {
      strcat(pStr, cStr);
      strcat(pStr, ayStr);
   }  
   printf("%s", pStr);                       
 //  return pStrPtr; 
}