Cloud9-Problem executing code

1

The following code:

#include <stdio.h>

void main()
{
    int num = 123;
    printf("O valor de num = %d e o valor seguinte = %c", num, num+1);
}

Returns the following result in the Cloud9 terminal:

  

The value of num = 123 and the next value = |

Can anyone help me figure out what's going wrong? Why is it that in the terminal it does not assume the sum of the variable?

The Browser used is Chrome Version 34.0.1847.137 m

    
asked by anonymous 16.05.2014 / 14:27

1 answer

7

You have an error in your printf. It should be

printf("O valor de num = %d e o valor seguinte = %d",num,num+1); 

As previously, with% c, printf would display the ASCII character corresponding to the given value. In this case, 124 corresponds to the vertical bar |.

Edit: You can find here the various formatting modifiers used in C and the corresponding output.

    
16.05.2014 / 14:36