Open BanDroid opened 1 year ago
You can send multiple inputs within the same string sent as input but separated by a new line feed \n
, here's how the curl request would then look like.
curl --location --request POST 'https://api.codex.jaagrav.in' \ --header 'Content-Type: application/json' \ --data-raw '{ "code": "import java.util.Scanner;public class MatSym {public static void main(String[]args) {Scanner in = new Scanner(System.in);System.out.println(in.nextLine());System.out.println(in.nextLine());}}", "language": "java", "input": "Hello\nWorld" }'
Import this on postman, make the request and you'll see the following response.
{
"timeStamp": 1672522998106,
"status": 200,
"output": "Hello\nWorld\n",
"error": "",
"language": "java",
"info": "openjdk 11.0.17 2022-10-18\nOpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu218.04)\nOpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu218.04, mixed mode, sharing)\n"
}
Please close this issue if your question is answered.
Thank you, this answer my question.
Hi @Jaagrav , i will re-open this issue again, there's issue with multiple inputs in static type language (such as java, c, c++, c#, etc).
If the code ask for multiple input that is not a string/character type, it will thrown error of type mismatch exception.
In your java example above, it ask for 2 string input. If you change to ask for int or other types, it will thrown error.
Maybe the input body should be changed into array instead of string and using \n
for separating input.
I figure it out, multiple input for numbers are separated by whitespace, but strings by newline. Should i close this issue? Maybe this could be unexpected bugs you didn't know
Is there a way to work with multiple input? For example the code is java, and asking twice for getting input from users.