How to replace a library function in C

2 Answers

0 votes
#include <stdio.h>
 
int myputs(char *);
 
#define puts myputs
 
int main()
{
    puts("abcd");
     
    return 0;
}
 
int myputs(char *str) {
    printf("myputs = %s", str);
}  
 
 
    
/*
run:
   
myputs = abcd
    
*/

 



answered Jun 28, 2024 by avibootz
0 votes
#include <stdio.h>
#include <string.h>

int myputs(char *);

#define puts myputs

int main()
{
    char str[32] = "abcd";
    puts(strcat(str, "XYZ"));
    
    return 0;
}

int myputs(char *str) {
    printf("myputs = %s", str);
}  


   
/*
run:
  
myputs = abcdXYZ
   
*/

 



answered Jun 28, 2024 by avibootz

Related questions

1 answer 233 views
233 views asked Jan 11, 2020 by avibootz
1 answer 145 views
1 answer 257 views
3 answers 436 views
3 answers 439 views
...