Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:55:56+00:00 2026-06-02T08:55:56+00:00

I got a syslog message <14>2012-04-19T03:54:18+08:00.527800 server3000 status: 00|00|The average CPU, memory, disk usage

  • 0

I got a syslog message

<14>2012-04-19T03:54:18+08:00.527800 server3000 status: 00|00|The average CPU, memory, disk usage and total network flow are 5.0%, 5.0%, 5.0% and 5 bytes respectively for the last hour.\n

How can I get the word 2012-04-19,03:54:18+08:00.527800,server3000,status,00,00 and 5.0 through the function sscanf?

#include <stdio.h>
#include <stdlib.h>

int main(void) {
int t1,t2 = 0;
char programname[20], deviceip[16], date[11], time[9];
char logmsg[30];
const char * s = "<14>2012-04-19T03:54:18.527800+08:00 server3000 status: 00|00|The average CPU, memory, disk usage and total network flow are 5.0%, 5.0%, 5.0% and 5 bytes respectively for the last hour";
sscanf(s, "<%*d>%[^T]T%[^.].%*[^ ] %[^ ] %[^:]: %d|%d|%[^\n]", date, time,deviceip, programname, &t1, &t2, logmsg);
return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:55:57+00:00Added an answer on June 2, 2026 at 8:55 am

    You may like to save the result of sscanf and check its value:

    int rc = sscanf(...);
    if(rc < 7)
        // failed to match or extract
    

    sscanf in your code returns 7, meaning that your format string matched and extracted all 7 arguments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got this error message while trying to load view: The model item passed into
Got a problem with selecting message from topic by message id. Here’s the boiled
I've got a simple Perl script that listens on a network port, accepts data
Got a problem with Apache and PHP-files of Wordpress. When I go to any
Got a programm with 2 threads. one thread is writing some stuff into the
got a simple web site, in html. I do a simple function to move
Got a question for some jQuery wizard who might stumble upon this. When I
Got a seg fault from my memcpy that gdb can't give me anything else
got a problem, can't get my head around this jquery and would appreciate your
got some problems. Built an applet that has to be used step-by-step. After each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.