mercredi 22 juin 2016

TypeError: expected a character buffer object: Autograder response

I have an assignment in which I must give an autograder multiple functions. Here is my code. Apparently, it will input the functions itself, which is why the main function is left blank. The functions all work properly, and CodeBlocks shows no errors, so I am clueless as to what is going wrong. #include <iostream> using namespace std; string outputTimeComponents(int numSecs){ int hours, minutes, seconds; minutes = numSecs/60; seconds = numSecs%60; hours = minutes/60; minutes = minutes %60; if (numSecs<0){ cout<<"This program cannot go back in time."<<endl; } else{ cout<<"The time is "<<hours<<" hours, "<<minutes<<" minutes, and " <<seconds<<" seconds"<<endl; } } int arrayOperations(int numOne, int numTwo, int numThree, int numFour){ int Array[numOne]; for (int i=0; i<numOne; i++){ Array[i]= numTwo+i; cout<<Array[i]<<endl; } cout<<Array[numThree]+Array[numFour]<<endl; } double stringComparator(string stringOne, string stringTwo, string comparisonType){ double Comparator=0; int kwyjibo; if (comparisonType=="same"){ for (int i=0; i<stringOne.length(); i++){ if (stringOne[i]== stringTwo[i]){ Comparator++; } else{ kwyjibo++; } } } else if (comparisonType=="diff"){ for (int i=0; i<stringOne.length(); i++){ if (stringOne[i]!=stringTwo[i]){ Comparator++; } else{ kwyjibo++; } } } else { return 0; } float divider=(Comparator/(stringOne.length())); cout<<divider<<endl; } double arrayOps(double arrayOfDoubles[], int arraySize, string opType){ double Bignum=0; if (opType=="calcSum"){ for(int i=0; i<arraySize; i++){ Bignum= Bignum+arrayOfDoubles[i]; } cout<<Bignum<<endl; } else if (opType =="calcAvg"){ for(int i=0; i<arraySize; i++){ Bignum=Bignum+ arrayOfDoubles[i]; } cout<<(Bignum/arraySize)<<endl; } else if (opType =="calcSumSquares"){ for (int i=0; i<arraySize; i++){ Bignum= Bignum+ arrayOfDoubles[i]*arrayOfDoubles[i]; } cout<<Bignum<<endl; } else{ return 0; } } int main() { return 0; } Here is the error message : 'Your code compiled correctly! However there were some warnings from the compiler: main.cpp:87:1: warning: control reaches end of non-void function [-Wreturn- type] } ^ Now attempting to link your code (second stage of compiling)... Your code linked correctly! Was able to re-compile your file with the function checker. Can now begin checking your functions Grading the outputTimeComponents function... Something went wrong running the function checker It gave this error: Traceback (most recent call last): File "/tmp/cogs/envs/run+942fa000-bd5d-4ce8-8533-edc58819c628/test/GradeAssignment3.py", line 459, in <module> sys.exit(grade(sys.argv[1:])) File "/tmp/cogs/envs/run+942fa000-bd5d-4ce8-8533-edc58819c628/test/GradeAssignment3.py", line 442, in grade score += gradeOutputTimeComponents(wrk_dir) File "/tmp/cogs/envs/run+942fa000-bd5d-4ce8-8533-edc58819c628/test/GradeAssignment3.py", line 156, in gradeOutputTimeComponents sys.stderr.write(stderr) TypeError: expected a character buffer object '

Aucun commentaire:

Enregistrer un commentaire