What will be the output??? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

What will be the output???

#include<iostream> using namespace std; int main() { char *s = "c++"; cout<<s<<" "; s++; cout<<s<<" "; }

6th Jun 2017, 7:41 AM
Rachit Tripathi šŸ˜˜
Rachit Tripathi šŸ˜˜ - avatar
7 Respostas
+ 7
#include <iostream> using namespace std; //change void main () to int main (void) int main (void){ char *s ="c++"; /* Interpreting as char array s[0] = 'c' s[1] = '+' s[2] = '+' */ cout<<s<<" "; //prints the entire char array ie "c++" /* by default s points to the first character in the char array ie s[0] s++ moves the pointer to the next character in the char array ie s[1] */ s++; cout<<s<<" "; //prints "++" }
6th Jun 2017, 8:07 AM
ą¤¦ą„‡ą¤µą„‡ą¤‚ą¤¦ą„ą¤° ą¤®ą¤¹ą¤¾ą¤œą¤Ø (Devender)
ą¤¦ą„‡ą¤µą„‡ą¤‚ą¤¦ą„ą¤° ą¤®ą¤¹ą¤¾ą¤œą¤Ø (Devender) - avatar
+ 7
it will show an error.....you are trying to store string in char....
6th Jun 2017, 7:58 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 7
void main šŸ˜’
6th Jun 2017, 8:02 AM
jay
jay - avatar
+ 6
Your code has no meaning at all.
6th Jun 2017, 8:04 AM
šŸ‡ŗšŸ‡ø AnatolišŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ ,
šŸ‡ŗšŸ‡ø AnatolišŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ , - avatar
+ 5
hmmm jay is right... change it to int main and return 0
6th Jun 2017, 8:03 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 4
ok guyss... changed void to int
6th Jun 2017, 8:07 AM
Rachit Tripathi šŸ˜˜
Rachit Tripathi šŸ˜˜ - avatar
+ 3
So the answer will be "c++ ++" ??
6th Jun 2017, 8:10 AM
Rachit Tripathi šŸ˜˜
Rachit Tripathi šŸ˜˜ - avatar