ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi All,
can anyone show me how to read the CID from a sd card in c(++) code? I've searched and found how to using cat /sys/block/mmcblk0/device/cid but can't find anyway in C. I could use system but don't know how I'd get the id numbers from that.
Thanks for the advise.
From within your program will you know the file to access all the time? Because you can use open() or fopen() from within the C program to open any file on the system, and then read from it. What I typically find is that I have to also do some in program research to find the correct file, because you can have stuff like /dev/sda1, or /dev/sdb2, and so forth and you want the correct reference file.
Since you appear to know the file name, you can open that file in C with open() or fopen() just as you could any other file.
And that would be "the way to do it in Linux."
All of these so-called "pseudo file-systems" are, in fact, a kernel API. This is the (only) way that the kernel presents this information to you. When you "open and read from" one of these "files" – and/or in some cases "write to" them – you are communicating with a kernel interface that is presenting data to you in text form.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.