What the difference between :

what the difference between:

1
2
3
4
5
6
  #include<iostream>
using namespace std;

void main(){
char a('1');
}

with this code :
#include<iostream>
using namespace std;

void main(){
char a=1;
}
Your first code value initializes a char (a) to the value of '1', or 49. The second code sets the value of a new char (a) to 1 (notice the number one, not the letter), or the symbol ☺.

You could just check this by in both cases "cout"ing the value of "a" and seeing what you get.

P.S. Don't use void main(), its non standard, use int main() instead.
Last edited on
Topic archived. No new replies allowed.