Thread: string to integer in pseudo

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    25

    string to integer in pseudo

    how do i write the atoi() command in pseudo code???

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you should ask the creator of the pseudo-code.
    Here is the C board, so we can only tell how to write the atoi in C
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    Something like this :
    Code:
    Convert String to Integer // Using atoi() in C for ex.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Just explain how you would program such a function in English. List the steps in as much detail as you can. That's all pseudo code is really. Except you don't have to use complete sentences.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Different places have different definitions of pseudo-code, there is no formal standard for pseudo-code.

    The term pseudo-code itself means "false code", or more loosely, "not real code". It could be C with simplified syntax or it could be plain english (perhaps with simplified forms), or it could look like Pascal or Fortran (with a more flexible syntax).

    The idea with pseudo-code is that it holds fewer details than the actual code, but describes the solution to the problem in a way that is relatively easy to translate into a programming language.

    As to the answer to the original question,I think King Mir gave a good answer: Describe step by step the process of converting a string into an integer.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    i would guess its just one line of code in C to convert an string to an int. The alternative to an atoi is to use sscanf(). ITs just a single statment. How would u think of to right a pesudo code for that. May be i would write it like this

    Code:
    Converted Integer value = atoi( String liternal which u wanted to be converted )
    I tired atleast

    ssharish

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > how do i write the atoi() command in pseudo code???
    "You mean like multiply current result by 10 and add the next character (in a loop)" kinda thing?

    Depends how detailed you want your pseudo-code to be.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Integer to string?
    By Blackroot in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2006, 06:13 AM
  4. Another overloading "<<" problem
    By alphaoide in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2003, 10:32 AM
  5. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM