I want to grade my students' HWs quickly so I decided to write a batch script for this purpose. I know it is easier to do it in Ubuntu but since students are required to code their HWs in Windows, I have to evaluate them in Windows as well. Well, so far I wrote the following piece of batch file but it doesn't take the char
variable.
Note that, purpose of the HW is draw a rectangle and fill it with the character given by keyboard (scanf
)
@echo off
set file=%1
gcc %file% -o %file%.exe
REM Followings are "row col fill" respectively
echo 6 10 A | %file%.exe :: #1
echo 6 6 | %file%.exe :: #2
move %file% graded\
move %file%.exe graded\
Here, both at #1 and #2, it draws the rectangle with spaces however at #1 it should fill it with A
s.
In case of my students can find this question on web, I can't put whole solution here but I can show the scanf() char
part:
//take num_of_rows and num_of columns
....
printf("\nFilling char?: ");
fflush(stdin);
scanf("%c",&fill);
...
//draw rectangle
And finally, here is the required output:
TEST-1
Enter number of rows (between 3-20) : 5
Enter number of columns (between 3-80) : 40
Enter a filling character (one char) : #
+--------------------------------------+
|######################################|
|######################################|
|######################################|
+--------------------------------------+
TEST-2
Enter number of rows (between 3-20) : 8
Enter number of columns (between 3-80) : 25
Enter a filling character (one char) : (blank)
+-----------------------+
| |
| |
| |
| |
| |
| |
+-----------------------+
WARNING: Please don't put whole solution of C code, since it is a HW.