Course Solutions Uncategorized (Solved) : Please Help M Trying Add Score Name Text File C Keep Getting File Could Opened Code Wrong Q38039039 . . . .

(Solved) : Please Help M Trying Add Score Name Text File C Keep Getting File Could Opened Code Wrong Q38039039 . . . .

 

Please help! I’m trying to add score and name on a text file inC but I keep getting “File could not be opened”. Is my codewrong?

#include <stdio.h>

//int scores(unsigned int theScore);

int main(int argc, const char * argv[])
{
   FILE *cfPtr = fopen_s(&cfPtr,”playerScores.txt”,”w”);
   unsigned int scores;
   char name[15];
   if (cfPtr == NULL)
   {
       puts(“File could not beopened”);
   }
   else
   {
       puts(“Enter score and name.”);

       fscanf_s(cfPtr,”%d%14s”,&scores, name);
      
       while (!feof(cfPtr))
       {
           printf(cfPtr,”%s %lf “, name, scores);

       }
      

       fclose(cfPtr); //fclose closesfile
   }
   system(“pause”);
}

Expert Answer


An answer will be send to you shortly. .

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post