Click here to Skip to main content
15,913,939 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiondisabling controls Pin
ashishmax473-Nov-08 18:27
ashishmax473-Nov-08 18:27 
AnswerRe: disabling controls Pin
Michael Dunn3-Nov-08 19:24
sitebuilderMichael Dunn3-Nov-08 19:24 
AnswerRe: disabling controls Pin
Hamid_RT3-Nov-08 19:38
Hamid_RT3-Nov-08 19:38 
Questionarray Pin
jonig193-Nov-08 17:35
jonig193-Nov-08 17:35 
AnswerRe: array Pin
CodingLover3-Nov-08 18:19
CodingLover3-Nov-08 18:19 
Questionstringstream formatting Pin
CodingLover3-Nov-08 16:35
CodingLover3-Nov-08 16:35 
AnswerRe: stringstream formatting Pin
chris_liush3-Nov-08 18:43
chris_liush3-Nov-08 18:43 
QuestionObject Noob Pin
Haun the 2nd3-Nov-08 16:15
Haun the 2nd3-Nov-08 16:15 
Ok so i have tried, and failed epically, to use objects. Even simple ones.

Now its seems that I need more than ever to understand how to use them.

my coding project is random, dont ask what it is for because i dont actually know my self.

What it does it generates a random number from 0-25 that is then used to assign a letter from my array alpha to a variable. 3 letter variables, and 2 number variables in the so called 'Mas' statement (A1B2C) and then the there are 5 number vars in the so called 'Address' statement.

I plan to have a total of 4 'Mas' statements, and thus 4 'Address' statements for the whole application

You can see why i need to learn how to use objects.

Here is the code:
<br />
#include <cstdlib><br />
#include <iostream><br />
#include <cmath><br />
<br />
using namespace std;<br />
// For examples, use  Mas: A1B2C Address: E12X123<br />
<br />
char masc1;//Mas char Eg (A)1(B)2(C)<br />
char masc2;<br />
char masc3;<br />
<br />
int masn1; //Mas numEg A(1)B(2)C<br />
int masn2;<br />
<br />
int idx1; //Index E(1)(2)X123<br />
int idx2;<br />
<br />
int idrt1; //Index Root Eg E12X(1)(2)(3)<br />
int idrt2;<br />
int idrt3;<br />
<br />
char alpha[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; //Alphebet array<br />
int pre; //used as a discardable var for the char assigner <br />
const int alphn = 26; // Our constant of 26 (0-25) the # of lettes in the alphebet <br />
const int num = 10; // number of digets 0-9 for index and root<br />
bool err = false; // If cker() is triped the core loop quits<br />
<br />
void masgen()<br />
{<br />
// random number generator + mas manufacturer<br />
    srand( rand()*(unsigned)time( NULL ) );<br />
    pre = (rand() % alphn + 2) % -alphn ; //rand pre for masc1 and idrt1<br />
		masc1 = alpha[pre];<br />
		idrt1 = pre;<br />
    pre = (rand() % alphn + 2) % -alphn; //rand pre for masc2 and idrt2<br />
		masc2 = alpha[pre];<br />
		idrt2 = pre;<br />
    pre = (rand() % alphn + 2) % -alphn; //rand pre for masc3 and idrt3<br />
		masc3 = alpha[pre];<br />
		idrt3 = pre;<br />
	pre = (rand() % num + 2) % -num; //rand pre for masn1 and idx1<br />
		masn1 = pre;<br />
		idx1 = pre;<br />
	pre = (rand() % num + 2) % -num; //rand pre for masn2 and idx2<br />
		masn2 = pre;<br />
		idx2 = pre;<br />
}<br />
<br />
void cker()<br />
{<br />
if( pre > alphn ) // if the pre is greater that actual data coverage (alphn)<br />
{<br />
    cout << "Error. Pre > Alphn \n"; <br />
    err = true; //Error has occured <br />
    system("PAUSE");<br />
}    <br />
}<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
while( err != true ) // inf. loop unless err is true<br />
  {<br />
 	masgen(); //runs mas gen<br />
	cker(); //runs the checker<br />
 	cout << "Mas: " << masc1 << masn1 << masc2 << masn2 << masc3 << '\n'; //Displays Mas<br />
	cout << "Address: " << "E" << idx1 << idx2 << "X" << idrt1 << idrt2 << idrt3 << '\n'; //Displays the Mas address<br />
    system("PAUSE");<br />
}<br />
system("PAUSE");<br />
return EXIT_SUCCESS;<br />
}<br />

AnswerRe: Object Noob Pin
Cedric Moonen3-Nov-08 20:27
Cedric Moonen3-Nov-08 20:27 
GeneralRe: Object Noob Pin
Haun the 2nd4-Nov-08 13:42
Haun the 2nd4-Nov-08 13:42 
AnswerRe: Object Noob Pin
Haun the 2nd8-Nov-08 7:20
Haun the 2nd8-Nov-08 7:20 
QuestionResource Templates Pin
Bram van Kampen3-Nov-08 15:24
Bram van Kampen3-Nov-08 15:24 
AnswerRe: Resource Templates Pin
Michael Dunn3-Nov-08 19:28
sitebuilderMichael Dunn3-Nov-08 19:28 
GeneralRe: Resource Templates Pin
Bram van Kampen4-Nov-08 11:31
Bram van Kampen4-Nov-08 11:31 
AnswerRe: Resource Templates Pin
cmk3-Nov-08 20:12
cmk3-Nov-08 20:12 
QuestionI loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
e_ilite3-Nov-08 15:15
e_ilite3-Nov-08 15:15 
AnswerRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
Hamid_RT3-Nov-08 19:42
Hamid_RT3-Nov-08 19:42 
GeneralRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
e_ilite3-Nov-08 20:44
e_ilite3-Nov-08 20:44 
QuestionRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
Mark Salsbery4-Nov-08 4:42
Mark Salsbery4-Nov-08 4:42 
AnswerRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
e_ilite4-Nov-08 14:01
e_ilite4-Nov-08 14:01 
GeneralRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
Mark Salsbery5-Nov-08 4:30
Mark Salsbery5-Nov-08 4:30 
GeneralRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
e_ilite6-Nov-08 14:42
e_ilite6-Nov-08 14:42 
GeneralRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
Mark Salsbery6-Nov-08 15:00
Mark Salsbery6-Nov-08 15:00 
GeneralRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
e_ilite6-Nov-08 15:04
e_ilite6-Nov-08 15:04 
GeneralRe: I loaded a bitmap from resource and share it with some windows to paint for background,but sometimes the bitmap will be changed to black? Pin
Mark Salsbery6-Nov-08 15:24
Mark Salsbery6-Nov-08 15:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.