the 2 backslashes

Hey everyone
I wonder why we use // this in C? I know that you say it locks the line but I don't undrestand the concept.Why do we need to do that? &what does it mean?

Thanks
2 backslashes are used in a string: "\\" prints \

2 slashes (//) are used for commenting a single line until end. The other comment is /* */. With that you have a problem to comment out the following: if(/*(x==0) &&*/ (y == 0))

if you want to comment out this line you use //: // if(/*(x==0) &&*/ (y == 0))
if you do that with /* */ you'll have a problem because the comment stopps at the first */
Last edited on
Thanks alot,but I still didin't get it!! You should explain for a reall beginer!
// marks the line as a comment. Comments are used to annotate the code.
1
2
3
4
5
6
7
8
9
10
11
12
/*This cool program prints text
Created by me*/

#include <iostream>

int main()
{
    // Place code to destroy the world here.

    std::cout << "Hello destroyed world!" << std::endl; // this line prints hello destroyed world to the screen
    return 0; // this line does something
}


You can use // to comment the line so you can remember what each line does or to find a specific place later to implement code
So it basicly does nothing?! Thanks guys,You are so nice :o)
What it does, I think, it annotates your source code. Kind of like an explanation to someone else who might get a hold of your work and might want to improve on it or fix errors.
Also it would serve to comment as to why the code was written a certain way or explanation or additional details on the code.

Think a paper with self annotations for future reference.
Topic archived. No new replies allowed.