Thread: lab sensor problem in c

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    2

    lab sensor problem in c

    Hi everyone
    I've got to write a program in c that
    monitor the usage of a laboratory at your university
    i need to take the following into consideration:
    1. Initialisation: At Power Up if there are some students inside the lab, the software should allow you to set this number as initial condition.
    2. If a student crosses one sensor BUT not the other THEN the count does not change and an error code is generated.
    3. You should allow for the lab supervisor to store MAXIMUM, MINIMUM and TOTAL number of students inside the laboratory for readings taken during one full day. As there are a number of lab sessions during any one day, your system should record each separate session.
    the 1 st and 2nd part is done however
    My only problem and the one holding me up currently is the 3rd part is how to record each seperate session.
    Im not asking for someone to give me the code ready but some hints on how to do it will be perfect thank you.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Write the information into files. Eg, you could create a directory and use one for each session. Maybe use the date as part of the name, so these records could be easily kept and sorted if desired. Better yet, just put the value from time(NULL) into a string, these will be unique (as long as you don't write two such files in the same second) and can easily be converted to a precise date and time. Then an identifying suffix, eg ".labsession"
    Last edited by MK27; 12-20-2011 at 06:44 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    2
    Quote Originally Posted by MK27 View Post
    Write the information into files. Eg, you could create a directory and use one for each session. Maybe use the date as part of the name, so these records could be easily kept and sorted if desired. Better yet, just put the value from time(NULL) into a string, these will be unique (as long as you don't write two such files in the same second) and can easily be converted to a precise date and time. Then an identifying suffix, eg ".labsession"
    thank you for ur help .i need to dig little bit in mkdir()funtion as i never heard of it before because its my first time writing in c language if you have any example on making directories and files in c will be much apreciated
    thanks again.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You might be better off creating the directory yourself rather than having the program do it, because creating directories is system specific (whereas creating files is not). Then one of the command line args could be the name of the directory to use. But if you want, for linux see:

    File System Interface - The GNU C Library

    "Creating Directories" is in that list.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Why bother with a separate directory, when a filename encoded with the time (down to a second) will be just as unique.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Salem View Post
    Why bother with a separate directory, when a filename encoded with the time (down to a second) will be just as unique.
    You can't be too well organized Altho it's not what I actually wrote, what I was thinking there was a per day directory and a per session file.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Water level sensor
    By Aneesha in forum C Programming
    Replies: 97
    Last Post: 07-01-2011, 07:22 PM
  2. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 10:13 AM
  3. OS sensor
    By Queatrix in forum Windows Programming
    Replies: 1
    Last Post: 07-11-2005, 07:00 PM
  4. Problem coding Banner sensor interrupt...
    By processing in forum C Programming
    Replies: 1
    Last Post: 02-14-2005, 04:41 PM

Tags for this Thread