C Read a column of a line from file -


I am reading / proc / diskstats (you know it or not) but no file is less, Which produces lots of lines and some columns / fields I'm asking for someone to show me how to get a row of columns back to that small data.

I have taken a look The output looks like this:

8 17 sdb1 15 0 38 28 0 0 0 28 28

So we have a few numbers (seems to be a long integer) and we have a string at the third position.

Now overall, we can read the output line by line, that is standard C for fgets. You may then use sscanf to select different elements. Without testing this something like

  sscanf (readline, "% d% s% d ....", & amp; var1, & var2 ....   

That "move" should not work in a combination of you, trying to read the line with the stroke.

Hope that gives you an idea.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -