mrnutty 761 Senior Poster

my apologies, for mistaking he for she. I usually assumed that
a person around here is a he,taking the risk of being wrong.

Anyways, hope the comment helped. Just a quick question.

Why do you need to learn this in a short period of time, especially
if you do not enjoy it?

Usually, a short period of time to learn the basics and some
advance stuff well, would take about a year ( at least for me).

mrnutty 761 Senior Poster

looking at your .txt file, you have the row and column backwards
in declaring your tmp array variable.

mrnutty 761 Senior Poster
try { ... throw("error") }
catch { const char *err)
mrnutty 761 Senior Poster

How about you dive into it and tells us if your stuck.

Make some classes, like level, character, food ...

so on from there

mrnutty 761 Senior Poster
ifstream iFile("text.txt"); //open file
  /****/
  whlie(!(iFile.eof() || iFile) //while there is stuff to read
 {
    // Read content.

 }
mrnutty 761 Senior Poster
sample s; //default ctor or if is provided then it is called
sample s1(s); //copy ctor is called
sample s2 = s1 ; //could use both copy ctor and assignment or just one.
sample s3;
s3 = s2; //use the assignment operator

sample s4( 5, "string") ; //use the provided ctor with same arguments.
mrnutty 761 Senior Poster

I think your template deceleration should look something like this :

template<typename Type1,typename Cont = vectors<int> >
class Stack { ... }
mrnutty 761 Senior Poster

very cute.

mrnutty 761 Senior Poster

Oh, its getting late :

try this :

pic_array[0] = read("data.txt",pic_count);
mrnutty 761 Senior Poster

No!!!


These are the exact same thing. If the block of code to be executed is only one line, no brackets are needed, though they don't hurt.

True. The compiler doesn't care of which way you use it,however, since
you are starting, you should use brackets so you can save mistakes from happening.

Salem commented: A consistent approach over option syntax will definitely save trouble at some point - good +36
mrnutty 761 Senior Poster

which part of overloading the << operator are you having
trouble with?

your prototype could be something like this :

std::ostream& operator<<(std::ostream& os, Real<T>& real);
mrnutty 761 Senior Poster

Maybe not killed, but laughed at, and your colleagues will implant viruses on your computer.

After that, who would want to live?

mrnutty 761 Senior Poster

Use [ code] [ /code] tags. You are missing a the while part
in your do while loop.

Using goto will get you killed (not really) in the c++ community.

mrnutty 761 Senior Poster

I would suggest the following :

1) create an abstract base class that has the similar properties for
all class

2) Derive a base class from the abstract, maybe a CarType class

3) Derive a Toyota, Honda, Lexus ... from CarType

mrnutty 761 Senior Poster

could you explain your problem.
also note that in c++ use should use cmath instead of math.h.
And forget about system(...) command. They are BAD.

mrnutty 761 Senior Poster

You ask the user to give you a number so you can
show every multiple answers of that number.

so int your loop check if the index 'i' is a multiple of that number,
if so then print the answer. Using the mod operator gives
the remainder of the division. If the remainder is a 0 , then the
number is a multiple of that number.

for example : 6 % 2 = 0. because 2 goes into 6 3 times with no
remainder.

mrnutty 761 Senior Poster

You are trying assign the int pic_count variable to a function that
returns string.

mrnutty 761 Senior Poster

do you include the brandon ? Also try putting the protype on top
of the main file.

mrnutty 761 Senior Poster

whats the exact error?

mrnutty 761 Senior Poster

when you say "put it", do you mean you copy the whole function
and redefine it in main?

mrnutty 761 Senior Poster

You do know that your array is of size 0 in this code :

string pic_array[pic_count];
	string used_pics[usedPic_count];

for your read function, use char *filename

mrnutty 761 Senior Poster

Here is an example :

int howMany = 0;  
 cin >> howMany; 
 for(int i = 0; i < 100; i ++)
       if(i % howMany == 0) cout << i;
mrnutty 761 Senior Poster

Look above

WaltP commented: What's this post supposed to mean? -4
VernonDozier commented: I think he was referring to my post here and posted the same thing, so he erased it. +22
mrnutty 761 Senior Poster

What have you tried?

mrnutty 761 Senior Poster

Not completely sure what you mean.

mrnutty 761 Senior Poster

Good Luck :)

mrnutty 761 Senior Poster

I have changed a little to your code ( which I mention in the code) :

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
//function to read inputs from the user test for proper input 
//and return the value to main if input is invalid, 
//the user will be repormpted for proper input

int validInput ( ) //CHANGED
{

	int userIn1 = 0;//ADDED
    int displayCount = 0;
    string userInput = "Please enter the number of terms to use: ";
           
           cout << userInput;
           cin >> userIn1; cout << endl;
           while ( userIn1 < 1)
                 {
                 cout << "Error, cannot be 0 or negative" << endl;
                 cout << userInput;
                 cin >> userIn1; cout << endl;
                 }
                                       
           return userIn1;
}

int main()
{
    
    int numCalc = 0;
    int userIn1 = 0;
    cout << "This program calculates the value of PI to varying degrees of accuracy " << endl;
    cout << endl;
    cout << "The accuracy is based on the desired number of calculations requested by user" << endl;
    cout << "The user may also decide the sequence of displayed output during calculations" << endl;
    cout << endl << endl;
    
    numCalc = validInput ();
    
    
    
     

   cout << endl << endl;
   system ("PAUSE");
   return 0;
   
}

But I am not sure which part you are stuck on. What compiler
are you using? Are you saying that this

string userInput = "Please enter the number of terms to use: ";                         cout << userInput;

does not print the string?

mrnutty 761 Senior Poster

Your porblem was :

Shapes::Shapes(char shape, int x, int y, int width, int height); <--THIS SEMICOLON
{
    cout << "You created a: " << shape " shape. At X: " << x " At Y: " << y " Width: " << width " Height: " << height << endl;
}
mrnutty 761 Senior Poster

"What the diffrent bettween while looping, conter-controlled while loop, sentinel-controlled while loop,flag-controlled while loop, do while loop and For loop. "

Their syntax and spelling:)

mrnutty 761 Senior Poster

If you want to print the users input then in your main you can
do this :

int main() 
{
   ...
   ....
     numCalc = validInput (userIn1);
   cout<<numCalc<<endl;
}
mrnutty 761 Senior Poster

I assume you want something like this :

int getInput ( int input) 
{
    cin >> input;
    cout << "your input : "<<input<<endl;
   return input;
}

In your function, you have validInput(int). It should be
int valudInput() // no parameters, since you want ask the user
to input a value inside the function. But the return type
should be an int if you want it to return the user's input.

Also this condition

while ( userIn1 < 1 ) //means the if userInput is 1 or below reject it.
mrnutty 761 Senior Poster

no problem. Mark this thread solved?

mrnutty 761 Senior Poster

If you want to validate that the user input is a number then
you can do it like so :

int num = 0;
  cout<<"Enter a number : ";
  cin >> num;
  whlie(!cin ) // check if the user inputs a valid data, i.e a number in this case
{
    cin.clear(); //clear the stream
    while( cin.get() != '\n')  //read all the fail input
     ;
     cout<<"\nPlease enter a number : ";
     cin >> num;
}
mrnutty 761 Senior Poster

where are you defining the userIn1 in your main function?

mrnutty 761 Senior Poster

if it changes its values then your functions should have
a non const array as a parameter like so :

void printtext(char **lotsoftext,int m,int n)

but you cannot pass a const array to it because the function
does not promise not to change its content.

mrnutty 761 Senior Poster

Its simple as this

float a = 3.1234567;
float b = int (a * 1000 ) / 1000.0f  // now b = 3.123
mrnutty 761 Senior Poster

Yes, and if your compiler does not support the keyword export,
then it has to be in the same file. (note not tested)
For example :

//pair.h
#ifndef PAIR_H_
#define PAIR_H
template<typename Type, template Type2>
class Pair
{
  private: 
   Type first;
   Type second;
 public:
   Pair() : first(0), second(0) { }
   Pair(Type a, Type2 b);
   
   void prntAll();
}

template<typename Type, typename Type2)
Pair<Type, Type2> :: Pair(Type a Type2 b) : first(a), second(b) { }

template<typename Type, typename Type2)
Pair<Type, Type2> :: prntAll() { std::cout<<first<<" , "<<second<<"\n";
}

#endif
mrnutty 761 Senior Poster

short answer : change

void printtext(char **lotsoftext,int m,int n)

to

void printtext(const char **lotsoftext,int m,int n)

Just a side note, when your function does not change the content of its arguments thats passed, then make
them const.

mrnutty 761 Senior Poster

Lets see what you are doing :

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int a, result, factorial(a);  //declare 'a' as an int
                                            //declare 'result 'as an int
                                           //declare 'factorial' as in int, initialized to
                                           //the value of 'a' which is ? junk...
{
cout << "please enter a number ";  //ask user for input
cin >> a; //read in the input
cout << factorial(a);    //display factorial(a) ??? I assume you believe
                                   //that factorial is defined in cmath, which is                                                
                                  //not, and if you do then why were you declaring it as a variable?
}


for(a=1; a>0; a--) //start a loop from a = 1 until a <=0, which means
                            //this loop will only execute once 
 {
   factorial *=a;  //now take the variable functions thingy and
                          //multiply it by a, which is 1 , which means the
                         //variable function thingy has not changed
  }
return 0; //return success, as if it were.
}
kvprajapati commented: No need to this post - See OP's post #1. He/She has missed code tags. -2
mrnutty 761 Senior Poster

make inner public. Then in you can access it by the scope resolution
operator like so outter::inner variable name;

[edit] The above assumes "outside " means from outside of the class.

mrnutty 761 Senior Poster

"I just want to have random numbers which are unique."

So whats the problem. Are you stuck somewhere, trying to implement
this? How about a trial and show us where/if you have problems.

Since its only 5 numbers, you can create an array that holds say 5 elements. Then fill the array only if the number
is unique (by checking the array).

mrnutty 761 Senior Poster

.

mrnutty 761 Senior Poster

" YOU (firstPerson): Hi! I'm the sucker who's gonna help you cheat your
class! Here's the code including comments! Say hi to your teacher for
me ok? "

Hilarious. Ok, no more freebies. I thought he was trying to learn
opengl. Didn't think that its a HW question. By the way is it Sunyah?

Nick Evan commented: Lesson learned :) +24
mrnutty 761 Senior Poster

when your display value reaches 60, you add 1 to minutes, and
keep doing this until your minutes adds to 1 hour;

Try this circular loop :

displayValue = ++displayValue % 60;
min = displayValue % 60 + displayValue/60
hour = min % 60  + min/60
mrnutty 761 Senior Poster

Your welcome. Now mark this thread solved.

[edit] Oh I see you have already done that:)

mrnutty 761 Senior Poster

strlen returns a unsigned int. And you can add a decimal to hex.

for example :

int a = 0xe; //14
     cout<<a<<endl; //display 14
    a = a + 1;  //now a = 15 or 0xf
   cout<<a<<endl; //display 15
mrnutty 761 Senior Poster

"If I delete a pointer, does it delete the data in the current address or
all of it?"

If you delete a pointer that variable no longer exist so every thing it
contains also gets deleted.

mrnutty 761 Senior Poster

Yes its normal. The first window is from your compiler, and the
second is where you render you objects.

It will be useful when you need to debug you application.

mrnutty 761 Senior Poster

Your problem is the variable qAnswer. you declare it before the
do while loop and inside it as well.

This code : while(qAnswer == 'y') uses the qAnswer before the
do while loop and not the one inside the loop. Thats because
the qAnswer variable thats inside the loop goes out of scope
before the condition, while(qAnswer == 'y') , is evaluated.

To fix you problem first initialize the qAnswer variable :

like so : char qAnswer = 'y';

Then delete the qAnswer inside the do while loop because thats
not needed. Your loop will use the one before the do while loop.

mrnutty 761 Senior Poster

What you are doing is very dangerous!

bool *dat; //create a  bool pointer
dat=new bool; //set bool pointing to a address, i.e pointer-to-bool
dat=true; //give value to the pointed address
++dat; //increase the address of bool. Huh-oh, but where is the
            //next address. Even worse, what does that address
           //contains? Important data ? maybe
dat=false; //what ever it had now its set to false
delete dat; //now you are deleting a vairable that points to a
                 //different that what it starts with!
--dat;        //Its deleted already, so huh?