Add a Makefile so that typing make compiles the program, reverse.c into the executable reverse.exec, and typing make test runs 3 tests. Typing make clean should remove any generated files.
Add a Makefile so that typing make compiles the
typing make test runs 3 tests. Typing make clean should remove any generated files.
Program for reverse.c:
#include <stdio.h>
char * make_reverse(char * word){
int i, len=0;
char temp;
while(word[len]){
len++;
}
for(i=0; i<len/2; ++i){
temp = word[i];
word[i]=word[len-i-1];
word[len-i-1]=temp;
}
return word;
}
int main(){
char str[]="James";
printf("%s", reverse(str));
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Logically it’s seems impossible to write a C program without using a main() function. Since every program must have a main() function because:-
- It’s an entry point of every C/C++ program.
- All Predefined and User-defined Functions are called directly or indirectly through the main.
Therefore we will use preprocessor(a program which processes the source code before compilation) directive #define with arguments to give an impression that the program runs without main. But in reality it runs with a hidden main function.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)