Like Matthew, I'm unable to replicate the error. When I import your question and run it, I get just the error that Matthew mentioned in his first posting.
Looking at your error output I think the key error is:
_tester__.c:7:38: error: expected ‘)’ before ‘char’
7 | #define SEPARATOR "##"char* getArrVZ() {
This shows that the template code
#define SEPARATOR "#<ab@17943918#@>#"
{{ STUDENT_ANSWER }}
has been expanded by Twig but has somehow had the tag-like substring <@17943918#@>
stripped and has had the white space collapsed. The collapsing of white space appears elsewhere in your error messages, too.
I've never seen this behaviour before but it looks like it is some special Twig behaviour. Twig does have a striptags filter that does something very similar (deletes tags, collapses whitespace) but it applies only within a Twig expression. I'm
not aware of any global setting that causes Twig to behave like that throughout the entire template.
So ... do you have any idea why your system should be behaving in this anomalous way? If not, can you tell me a bit about your Moodle/CodeRunner install, please? Specifically:
- What version of Moodle are you running and is it a Linux-based server or a Windows-based server?
- When was CodeRunner installed on this Moodle server (i.e. is it a recent addition or an old one)?
- Has CodeRunner worked OK in the past?
Also, just to confirm that my diagnosis is correct, could you include the source code output from the run in your response, please? It should be as follows but I think it will actually look like it has been rendered as HTML.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
s#include <string.h>
#include <stdbool.h>
#include <math.h>
#define SEPARATOR "#<ab@17943918#>#"
char* getArrVZ() {
char arrvz[42];
arrvz[0]='v';
for(int i=1; i<42; i++) {
if(i%2 == 0)
arrvz[i] = 'v';
else
arrvz[i] = 'z';
}
return arrvz;
}
int main() {
{
printf("%c",getArrVZ()[0]);;
}
printf("%s\n", SEPARATOR); {
printf("%c",getArrVZ()[11]);;
}
printf("%s\n", SEPARATOR); {
char t = getArrVZ()[42];
if(t == 'v' || t == 'z')
printf("bad");
else
print("good");;
}
printf("%s\n", SEPARATOR); {
for(int i=0; i<42; i+=2)
printf("%c",getArrVZ()[i]);
}
printf("%s\n", SEPARATOR); {
for(int i=1; i<42; i+=2)
printf("%c",getArrVZ()[i]);
}
return 0;
}