I was searching for how to add two numbers without using ('+'/'++') and went through link. But, I also found this solution:
#include<stdio.h>
int add(int x, int y);
int add(int x, int y)
{
return printf("%*c%*c", x, ' ', y, ' ');
}
int main()
{
printf("Sum = %d", add(3, 4));
return 0;
}
Can somebody explain what's happening in add function?
return snprintf(NULL, 0, "%*c%*c", x, '#', y, '#');and not mess up the output. Anyway, this method will never work with negative values!