“The Killer Robot program won’t run correctly.” An middle-school student beckoned Artyom to her computer in the lab.

“Let me have a look.” Artyom pulled one of the child-sized chairs and sat next to his student. He had given his class some educational, open-source C programs to try out. Killer Robot looked like good, text-based fun, according to the SourceForge description.

“I compiled it in Edu-C,” she said, “but when I run the program the robot’s legs don’t move. I can’t smash any cities.”

“Okay, I’ll teach you how to debug it.” Artyom opened killerrobot.c in the Edu-C editor and was astonished by the elaborate comments:

// ^X 
// | 
// | 
// *----->Y 
// 
// Z down 
... 
// -----* 
// c \ f 
// \ 
// * 
// | t 
// | 
... 
 double acos_1; 
... 
 //----* 
 // |\ 
 // | \ 
 // |^ \ 
 acos_1 = (b2 + f2 - t2) / (2 * f * b); 
 printf("ac1=%.3f\n", acos_1); 

“It always prints 0 for acos_1,” the student said. “It’s that printf line, right? The line setting acos_1 looks okay. Do you know what’s wrong, Mr. Artyom?”

“No, I don’t.” He stretched his arms. “A good programmer needs to be creative. Any ideas?”

“...Maybe set acos_1 to something else, and see what happens?”

Artyom nodded, changing the robot leg code to this:

 //----* 
 // |\ 
 // | \ 
 // |^ \ 
 acos_1 =1.0;//(b2 + f2 - t2) / (2.0 * f * b); 
 printf("ac1=%.3f\n", acos_1); 2

“Huh, it still prints 0,” the student said. “And why do those comments look funny? Everything after that backslash is colored in, like it’s not commented out.”

Artyom recalled the description of Killer Robot in SourceForge. “It’s supposed to be compiled in GCC, another compiler that people can use for free. But we’re trying to compile it in Edu-C. Maybe Edu-C doesn’t know how to read those comments correctly, so the backslashes--”

“--Are being compiled too, making it error out.” The student looked proud of herself.

The computers in the lab all had GCC installed. Artyom showed his student how to compile the program from the command line. “Now that you know, can I trust you not to write a program that will take over the school?”

“Promise,” she said.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!