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
telephone pointer program
Collapse
X
-
Tags: None
-
i'm still doing reseach for this program,i just ask any ideas will helpOriginally posted by NkhosinathieThis 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++ ?Originally posted by NkhosinathieThis 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
SavageComment
-
yes sir i'm doing this research program using a c++ languageOriginally posted by SavageAre you using c++ ?
SavageComment
-
-
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 pointersOriginally posted by sicarieSeems 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
-
OK,it will be a little bit more complicated then.Originally posted by Nkhosinathiethe 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
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.
SavageComment
-
thanks sir for the help,but may i ask? what if i want my program also to generate those phone numbers randomly?Originally posted by SavageOK,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.
SavageComment
-
Please stop calling me sir.I feel uncomfortable.W e all here study and/or work for living.Originally posted by Nkhosinathiethanks sir for the help,but may i ask? what if i want my program also to generate those phone numbers randomly?
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?
SavageComment
-
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 sirOriginally posted by SavagePlease 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?
SavageComment
-
This is what i meant.Originally posted by Nkhosinathiei 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
[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
Comment