Hi, I m facing some trouble in c++?
I want to know how to write equivalent c++ statement from these c codes

struct stat sb; // this is struct, will be same in c++



printf("I-NODE NUMBER:      %ld\n", (long) sb.st_ino); // this is C statement

// c++ statement of above statement


cout<<" Inode number: "<< (long) sb.st_ino; // is this the correct way?

// or this one

cout<<" Inode number: "<< (long) (long) sb.st_ino; // is this the correct way?
cout<<" Inode number: "<< sb.st_ino;

You only need the long if you want it explicitly cast to a long. If you do want to cast and you want the code to be c++ then you could do this:

cout<<" Inode number: "<< static_cast<long>(sb.st_ino);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.