telephone pointer program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nkhosinathie
    New Member
    • May 2007
    • 91

    telephone pointer program

    This isn't a homework,i want to improve my skills in programming and apply my understanding to pinters. i'm developing a program that will print telephone numbers randomly for a city for instance(maybe use a code for (011) and those telephone numbers should be equal to 10 numbers. so may someone please give a clue how to start this beautiful thinking of mine.thanks
  • Nkhosinathie
    New Member
    • May 2007
    • 91

    #2
    Originally posted by Nkhosinathie
    This isn't a homework,i want to improve my skills in programming and apply my understanding to pinters. i'm developing a program that will print telephone numbers randomly for a city for instance(maybe use a code for (011) and those telephone numbers should be equal to 10 numbers. so may someone please give a clue how to start this beautiful thinking of mine.thanks
    i'm still doing reseach for this program,i just ask any ideas will help

    Comment

    • Savage
      Recognized Expert Top Contributor
      • Feb 2007
      • 1759

      #3
      Originally posted by Nkhosinathie
      This isn't a homework,i want to improve my skills in programming and apply my understanding to pinters. i'm developing a program that will print telephone numbers randomly for a city for instance(maybe use a code for (011) and those telephone numbers should be equal to 10 numbers. so may someone please give a clue how to start this beautiful thinking of mine.thanks
      Are you using c++ ?

      Savage

      Comment

      • Nkhosinathie
        New Member
        • May 2007
        • 91

        #4
        Originally posted by Savage
        Are you using c++ ?

        Savage
        yes sir i'm doing this research program using a c++ language

        Comment

        • sicarie
          Recognized Expert Specialist
          • Nov 2006
          • 4677

          #5
          Originally posted by Nkhosinathie
          yes sir i'm doing this research program using a c++ language
          Seems like you'll need to decide how you are going to store the numbers (the format), and how they will be stored (with other numbers) in a collection. (Maybe the STL can help you there?)

          Comment

          • Nkhosinathie
            New Member
            • May 2007
            • 91

            #6
            Originally posted by sicarie
            Seems like you'll need to decide how you are going to store the numbers (the format), and how they will be stored (with other numbers) in a collection. (Maybe the STL can help you there?)
            the problem is we arev still doing pointers so we haven't reached the data structures yet so my program should include only arrays and pointers

            Comment

            • Savage
              Recognized Expert Top Contributor
              • Feb 2007
              • 1759

              #7
              Originally posted by Nkhosinathie
              the problem is we are still doing pointers so we haven't reached the data structures yet so my program should include only arrays and pointers
              OK,it will be a little bit more complicated then.

              You said that telephone number should have 10 digits,right?

              If you are familiar with functions,you could create one that will read telephone number from a istream,and add it to your's big array of telephone numbers.

              Savage

              Comment

              • Nkhosinathie
                New Member
                • May 2007
                • 91

                #8
                Originally posted by Savage
                OK,it will be a little bit more complicated then.

                You said that telephone number should have 10 digits,right?

                If you are familiar with functions,you could create one that will read telephone number from a istream,and add it to your's big array of telephone numbers.

                Savage
                thanks sir for the help,but may i ask? what if i want my program also to generate those phone numbers randomly?

                Comment

                • Savage
                  Recognized Expert Top Contributor
                  • Feb 2007
                  • 1759

                  #9
                  Originally posted by Nkhosinathie
                  thanks sir for the help,but may i ask? what if i want my program also to generate those phone numbers randomly?
                  Please stop calling me sir.I feel uncomfortable.W e all here study and/or work for living.

                  Now to the problem:

                  You can also write a simple function.To lower the space needed and compatibility whit char arrays,you can randomly generate 10 chars(chars can range from -127 to 128 and you need only a single digit ranging from 0-9) and merge them into single string which you will then return.Do you know how to generate random numbers?

                  Savage

                  Comment

                  • Nkhosinathie
                    New Member
                    • May 2007
                    • 91

                    #10
                    Originally posted by Savage
                    Please stop calling me sir.I feel uncomfortable.W e all here study and/or work for living.

                    Now to the problem:

                    You can also write a simple function.To lower the space needed and compatibility whit char arrays,you can randomly generate 10 chars(chars can range from -127 to 128 and you need only a single digit ranging from 0-9) and merge them into single string which you will then return.Do you know how to generate random numbers?

                    Savage
                    i know how to generate numbers i can use function srand(time(0)) to generate those numbers,but now i'm confused about the simple function you suggested to lower the space,may you give me an example of it.and i've already started with the program i'll show you shortly what i've done so far and i apologise for callin you sir

                    Comment

                    • Savage
                      Recognized Expert Top Contributor
                      • Feb 2007
                      • 1759

                      #11
                      Originally posted by Nkhosinathie
                      i know how to generate numbers i can use function srand(time(0)) to generate those numbers,but now I'm confused about the simple function you suggested to lower the space,may you give me an example of it.and I've already started with the program I'll show you shortly what I've done so far and i apologies for calling you sir
                      This is what i meant.

                      [CODE="cpp"]
                      //function declaration
                      .
                      .
                      //function body start
                      char array[10];

                      for(int i=0;i<10;i++)
                      {
                      //generate a number and store it into array[i],make sure that number is from range 0-9
                      //add to array[i] '0' so that it really become a string of digits,and not of invisible characters(Chec k ASCII table)
                      }

                      return array;


                      //function body end


                      [/CODE]

                      Comment

                      Working...