array navigating problem

This is a discussion on array navigating problem within the C Programming forums, part of the General Programming Boards category; Hi I wanted to know if you can describe how next record, first record, previous record and last record work ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    30

    Lightbulb array navigating problem

    Hi

    I wanted to know if you can describe how next record, first record, previous record and last record work if i want to navigate in the array.

    thanks
    Kendals

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is a very vague question.

    Record array[SOMESIZE];
    Record *first, *current, *next, *prev;

    first = array[0];
    current = array[CURRENT];
    prev = CURRENT < 1 ? 0 : CURRENT -1;
    next = CURRENT < SOMESIZE -1 ? CURRENT + 1 : SOMESIZE -1;

    That should do the trick.
    Additionally, you could use pointer math to handle this instead of using a counter. Subtract pointer1 from pointer2 and compare the numerical difference.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    30

    thanks

    thanks, is there a standard for pseudocode? or can you describe it as structured english?
    Kendals

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What do you mean? Generally speaking, you can just form it as english. However, there is nothing pseudocode about that. Define a constant (or #define) to hold your array size. Declare a variable called 'CURRENT', and apply it to the above. typedef your data type to 'Record', and there you have 100% working C code.

    Anyway, pseudocode is usually done in standard english:
    Code:
    if mybills > myincome
        output "You'll go broke soon."
    else
    if mybills == myincome
        output "You'll never get out of debt."
    else
        output "You'll be out of debt soon."
    Pesudocode is meant to be "understandable to the non programmer", or perhaps "a guideline for the programmer". It's good to think of pseudocode as an outline for a report.

    You can simplify your pseudocode as much as you need, or make it as complex as you desire.

    One way to build your project overview is to make very simple pseudocode to outline it, then break each step down into more and more complex results until you end up with the final product. Shrug.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array problem
    By TomBoyRacer in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2007, 11:35 AM
  2. Problem Putting INTs Into a CHAR Array
    By cram in forum C++ Programming
    Replies: 13
    Last Post: 10-13-2004, 07:53 AM
  3. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 11:09 AM
  4. Need desperate help with two dimensional array problem
    By webvigator2k in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2003, 02:28 PM
  5. From stream/file to a string array problem
    By dradsws in forum C Programming
    Replies: 2
    Last Post: 10-01-2001, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21