Changing the Output Without Changing the C Program
#include<stdio.h>
int main( )
{
printf("\n1\n");
printf("\n2\n);
printf("\n3\n);
}
The Output of the Program is Shown Below
The task is to get the output shown below without making any change in the "C Program".
Solution:-
The idea is to assemble the C Program into assembly file and make changes there. To learn step by step compilation of C Programs in Linux please visit my previous post. I have shown the process in the below.
- Let the C Program be named as a.c.
- Edit the file a.s. The changed program is shown below.
- Now compile the a.s file by typing the command gcc a.s. The output file a.out is generated.
This Post also gives you an idea about optimizing C Programs by making changes in the Assembly language file.