Read a Log line by line and show error if codes same

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kooroshkdt
    New Member
    • Nov 2009
    • 5

    #1

    Read a Log line by line and show error if codes same

    hi everyone,
    i'm not beginner but i learn programing in hack kind, i don;t have any idea about my problem(in C++ wrote)!!! Read Plz post if u have any Idea, i want to here it, it will be your kind if u post here!!!


    i have a program that program creating a log file just like this format,

    Year 2009,Month 10,Day 15,Time 11:10:48,Code 432
    Year 2009,Month 9,Day 29,Time 11:10:48,Code 442
    Year 2009,Month 11,Day 1,Time 11:10:48,Code 495
    Year 2009,Month 11,Day 4,Time 11:10:48,Code 415
    Year 2009,Month 11,Day 7,Time 11:10:48,Code 400
    Year 2009,Month 11,Day 9,Time 14:12:10,Code 415



    i need codes for read last line first ,and show Warrning msg if last Code used in earlier than one week (mean 168 hours) !!!
    and if times like it :
    14:12:10
    11:10:48
    calculate it in int mean show=3 hours
    but if u don't have idea , with time checking forget it !!!


    just write codes if program saw last line code if have same code with any line show warning


    guys i need help of all u !!! i can change log format just if u have any idea!!! post it here


    Regards
    Kourosh
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Is there a reason you need to use C/C++ to solve this problem? It would be easier to solve this problem using Perl.

    Comment

    • newb16
      Contributor
      • Jul 2008
      • 687

      #3
      The reason is it's an assignment. (see topic 876678)

      2OP - for parsing time like 11:10:48 in your case I'd use sscanf(...,"%d: %d:%d", ...)

      Comment

      • kooroshkdt
        New Member
        • Nov 2009
        • 5

        #4
        Originally posted by donbock
        Is there a reason you need to use C/C++ to solve this problem? It would be easier to solve this problem using Perl.
        there is Just one problem, i don't know perl,and i wrote my program with C++ it's better if i use one application!!! but if u can, plz post your perl code, i try to find way to use it!!!


        Thank you for giving Time
        Regards
        kourosh

        Comment

        • kooroshkdt
          New Member
          • Nov 2009
          • 5

          #5
          can u explain a bit more!!!
          plz

          if u can plz Write a Sample,of course if u have time for it!!!


          Regards
          Kourosh KDT

          Comment

          • kooroshkdt
            New Member
            • Nov 2009
            • 5

            #6
            Originally posted by newb16
            The reason is it's an assignment. (see topic 876678)

            2OP - for parsing time like 11:10:48 in your case I'd use sscanf(...,"%d: %d:%d", ...)
            can u explain a bit more!!!
            plz

            if u can plz Write a Sample,of course if u have time for it!!!


            Regards
            Kourosh KDT

            Comment

            • newb16
              Contributor
              • Jul 2008
              • 687

              #7
              I'm inclined to reply with the traditional reference to http://bytes.com/faq.php?faq=posting..._or_coursework
              Did you try to find sscanf reference and apply it to your needs?

              Comment

              • kooroshkdt
                New Member
                • Nov 2009
                • 5

                #8
                Originally posted by newb16
                I'm inclined to reply with the traditional reference to http://bytes.com/faq.php?faq=posting..._or_coursework
                Did you try to find sscanf reference and apply it to your needs?
                my home works finished 3 years ago!!!
                if i use assigments cuz some times u must ,try solve some question to don't forget what u learn years ago!!!
                i pass my Programing exam in univercity with 96 but it's 3 years ago!!! not now !
                no one give u homework like this to u !!!
                i can ask it from teachers but i think better to ask this from another kinds of programers cuz always u can find some thing on internet , just genius can find it in real,
                and if it's home work , i don't ask for perl code !!! see before reply!!! i think it's enough for your answer my friend! ;)

                Comment

                Working...