In c if I have a return value and do not catch it, will this cause any problems in my program?

Or should I just catch it in some dummy variable and discard it?

In spite of googling.. I can't find any info in how c behaves in this type of situation. Anyone?


Do you generally catch the return value of printf ?

If you don't need to use the return value, you can quietly discard it if you so choose.

It's syntactically correct and there's really no harm in it except for the fact that its a complete waste since the reason you have a function returning a value is because you want to use it. If you don't want to return a value then a function returns void.

#include <stdio.h>

int add(int x, int y)
  return x + y;

void print_add (int x, int y)
  printf("%d\n", add(x, y));

int main()
  add(5, 10); // does nothing
  print_add(5, 10); // outputs 15
  return 0;

Disregarding a return value is harmless. Well with that said I should mention that the return value is lost but if its deemed insignificant then no harm done