mrnutty 761 Senior Poster

Hey guys, thanks a lot for the support. I talked to her yesterday, and actually I feel
a lot better after the talk we had. We decided to be close friends, while she does some soul
searching of her self. God bless you guys.

mrnutty 761 Senior Poster

This my friend is what true love
is. I feel the need to share you a story, a wonderful story. Yesterday night, I pondered
about heaven and how I couldn't wait for the eternal happiness. I prayed and talked to god.
Today I received a message. I felt such a rush of happiness that I never felt before in my
life. This was during work at Dunkin-Donuts. I cannot even begin to describe the happiness
that I felt. I was about to tear up. From that moment on, I seen people in a whole
different light. I have learned to love god's creation. I am very happy that god accepted
me and gave me a feeling of immense happiness. This happiness that I felt, is which I
believe, I will feel again once I enter heaven. I felt the need to spread the word about
god. Thank you very much for reading.

iamthwee commented: God bless +0
mrnutty 761 Senior Poster

Seems like at your level, you don't need to worry about header files, because it will
only complicate things for you. Just stick with 1 file for now, the main file.
And by the way all of this is valid :

int a;
int aa;
int aaa;
int b;
int c;
int abc;
int ac;
int ab;

You see, what matters is that NO TWO VARIABLE NAMES ARE THE SAME, if you follow that
then you will be fine.

mrnutty 761 Senior Poster

I haven't compiled myself, but this is very confusing:

typedef struct node{

	int data;
	struct node *next;
	struct node *previous;
}mynode;

mynode *head,*temp,*current,*tail;

First, why have you used a typedef? Second, you seem to have declared an object named mynode, then tried to declare things (head,temp,etc) of type mynode. Shouldn't they be type 'node'?

The main reason for doing this is backward compatibility. In C, you have to use the
keyword struct before declaring a struct variable. So usually, programmer use typedefs
to simply things and make things easier. But In C++, thats not required.

mrnutty 761 Senior Poster

First make use of const. Second in your NumberToString function, what happens
when the conversion fails? When the stringstream cannot convert the object passed in?
Handle those extreme cases as well. Also in your ContainerToString function, you
could just as well use a forward Iterator and it would work.

mrnutty 761 Senior Poster

I'm trying so hard not to contact her. Right now we are friends. But right now,
I'm just remembering the past and how good it was, how much she loved me at that
time, but her complicated ass, gets crazy and starts thinking so so deeply when
she is alone, and has free time, which she has a lot of during the summer. I realize
that only time will heal this pain. I feel so shitty. I hate relationships, well at
least the break up part of it. Thanks guys for the support. I talked about this with
my friends and that definitely made me feel better.

mrnutty 761 Senior Poster

Because the compiler see's it as :

int triangle(int);
mrnutty 761 Senior Poster

Or just this :

string str[5] = {"hello","ramble","people","kitty","rope"};
vector<string> vec(str,str+5);
mrnutty 761 Senior Poster

How do I get over a break up? I am feeling really shitty. My ex girl who was my
first just gave me the "we should be friends" card. Actually we been on and off
lately because of some complicated stuff. But now, I don't want to go back, and since
she broke up( again ), I am not going back if she asks because I am tired of this rollercoaster. But right now I feel really really shitty. Been thinking about her the
whole day. Went to gym to relax my mind, and it worked a little but now the shitty feeling
is back. Any advice from the more experience?

jonsca commented: Hang in there +0
mrnutty 761 Senior Poster

All of these foolish replies. The guy is asking for help and you guys are messing
around. So let me say this, let it be natural, don't be awkward, be confident especially, since girls don't like wimps, and start a conversation. Since you are new in the class, ask her help with a problem in the class, or ask her to help you get around, and when she says yes, start another conversation about her. Ask her questions about her( like how does she like it here in this school). But make sure she does not have a boyfriend, otherwise you might get into a fight or something, or
you'll at least be friends with her. But remember this, don't think you can just
get her to be her girlfriend in a day, work for it. And most of all, like I said,
be confident, and good luck. Make sure you update us for the good news. OH and also
present you self well, smell nice, look nice, act nice, and girls will be NICE to you
if you know what I mean.

mrnutty 761 Senior Poster

you have the starting position and the length of the string, so just start reading character by character from the starting position length number of times.

mrnutty 761 Senior Poster

umm....

#include <iostream>
#include <string>
using namespace std;
int main(){
 string str = "@#@#@";
 cout << str << endl;
}

That will be $50 please.

mrnutty 761 Senior Poster

Simpler version of your problem:

#include <iostream>
int main(){
 using namespace std;
 int a = 0;
 string str;
 cin >> a;
 getline(cin,str); //skipped??
}

the problem is when you use cin to read in a number, there is a newline that gets
stuck in the buffer, because cin disregards whitespaces and newlines. Thus that
newline is read into the string, and does not read in the user input. So to solve
this problem, you need to read the buffer to discard the newline. There are many
solutions to this. One ways is the way you found it, using cin.get. Others uses
cin.ignore and such.

mrnutty 761 Senior Poster

Is there a total amount she made? There is only 4 prices listed for 5 items, and the
requirement says that every profit was a unique amount.

Anyways, here is my guess, can you tell me if its correct or not.
1) popcorn[$25]
2) candybars[$60]
3) lollipops[$75]
4) fudge[$45]
5) taffy

mrnutty 761 Senior Poster

you know, this post seems suspicious. It looks like( at lest to me) that you are
trying to get someone else's code, who wrote it a while back, to compile so you can use
it either for h.w or for some school related stuff? If you don't get what graphs are
then go study more theory and ask specific questions, otherwise good luck cheating.

--------------------
PS: forgive if I was wrong.

mrnutty 761 Senior Poster

Will that operate on std::list ?

Sure, just try it,

#include <iostream>
#include <list>
#include <algorithm>
#include <string>
#include <iterator>

template<class Coll>
void print(const Coll c){
	using std::cout;
	using std::endl;

	typename Coll::const_iterator itr = c.begin();
	cout << "{ ";
	while(itr != c.end()){
		cout << *itr++ << " ";
	}
	cout << "}";
}
int main(){	
	using namespace std;
	string s1 = "abc";
	string s2 = "abd";
	list<char> a = list<char>(s1.begin(),s1.end());
	list<char> b = list<char>(s2.begin(),s2.end());
	list<char> res;

	std::set_difference(a.begin(),a.end(),b.begin(),b.end(),std::back_insert_iterator<list<char> >(res));
	print(a);
	cout << " - ";
	print(b);	
	cout << " = ";
	print(res);
	cout << endl;

	return 0;
}
mrnutty 761 Senior Poster

The easiest way to do this is use stl's, set_difference.

mrnutty 761 Senior Poster

If you use a class or struct, did you forget to put a ; at the
end of the class/struct declaration?

mrnutty 761 Senior Poster
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>


using namespace std;

int main()

{
        srand ((unsigned) time(0) ); //<----Only seed once	
//A string is not necessary, you aren't using any the facilities of the class
        char* RandNum;
//What is this supposed to do? There's no input from the user?	
        char UserLetter; // what the user will enter  and the place of storage in char


	for (int i=0; i <10; i++)	
	     RandNum[i] = 65 + rand()% 26;

	cout << RandNum << endl;
	return 0;
}

There is no need to cast a string to a char* anyway since cout already knows what a string is and can output it just fine

really, I mean come on. RandNum is never allocated, but still written into. Plus its
not null-terminated. And on top of that you tell him not to use std::string, SMH.

Even though, he might not need to use string's capability now, he might later on. And
at the very least, he does not have to worry about dynamic memory management.

mrnutty 761 Senior Poster

While it's not the rule of the thumb, but operators should generally return the new value, for chain assignment.

money &operator + (const money &rhs) const //Again reference

arghh, it was a question for OP, so he can think. It wasn't a question for me.

mrnutty 761 Senior Poster

So basically you need the Arithmetic difference of both arrays, something like this:

int* getDiff(int *arr1, int *arr2)
{
  int maxCount = 1750; //From your 1st Post
  int *result = new [maxCount];
  for(int i=0 ; i<maxCount ; i++ )
    result[i]=arr1[i]-arr2[i];
  return result;   
}

Ouch, thats pretty bad. I would have just used stl,

#include <algorithm>
#include <functional>
#include <vector>
using namespace std;
int main(){
 //std::vector is better, just using arrays for demonstration
 const int SZ = 5;
 int a1[SZ] = {1,2,3,4,5};
 int a2[SZ] = {5,4,3,2,1};
 int res[SZ] = {0};
 std::transform(a1,a1+SZ,a2,res,std::minus<int>());
 
}
mrnutty 761 Senior Poster

>>You have to use ofstream, not just fstream

fstream inherits from ifstream and ofstream, so it can do both, read and write.

mrnutty 761 Senior Poster

hi Everyone,

I'm working with a Text file. Somewhere in my code a function returns the current position of the file pointer. But i want it to go to the next line or 2 lines after to do a string search there. Anybody knows how i can do that?

Bests,

If you want the file pointer to goto the next line, then just use the getline(...) funtion
to read in the current line as a dummy. And the file pointer will proceed to the beginning
of the next line.

mrnutty 761 Senior Poster

>>operator + (const money rhs) const

I guess no one else saw this, but you need to specify the return type for any function.
What should the return type of operator+ should be, in other words, what should the
addition operation return for this class?

mrnutty 761 Senior Poster

>>I believe that using a new two-dimensional array is the way to go,
Why do you think so?

mrnutty 761 Senior Poster

You need to break things into functions so its more readable. Also try this :

while (arquivo && getline(arquivo, arquivo_linha))
mrnutty 761 Senior Poster

huh?

mrnutty 761 Senior Poster

Mind explaining, what exactly do you mean?

mrnutty 761 Senior Poster

In C++ use getline :

#include <string>
#include <vector>
#include <sstream>
#include <iostream>
using namespace std;

std::vector<string> explode(const string& text, char delim){
 std::vector<string> res;
 string temp;
 stringstream ss(text);
 while(ss && getline(ss,temp,delim) ) res.push_back(temp);
 return res;
}

int main(){
 std::vector<string> vec;
 vec = explode("hello world",' ');
 cout << vec[0] << endl; //hello
 cout << vec[1] << endl; //world
}
mrnutty 761 Senior Poster

In screen coordinate system i.e top left corner = (0,0) and bottom right corner = (800,600), How can we find the equation of a line given ?

Also how the intersection point of this line can be calculated with the screen boundary ?

Do you actually put image using the pixel coordinates. Or do you(or your API) transform it into world coordinates?

mrnutty 761 Senior Poster

Yes what does difference mean in your case ?

difference1 : 4 - 3 = 1
difference2 : {a,b,c} - {a,d,f} = {b,c}

mrnutty 761 Senior Poster

You pass num1 which is a vector of ints, and you pass its start position and its end
position, thats redundant. Makes the user do extra code. And you can't print a vector
using operator<< without defining the operator<<.

mrnutty 761 Senior Poster

First, FDT_filename[0] is not valid because there is nothing inside the vector.
But to fix your error, use FDT_filename[0].c_str().

mrnutty 761 Senior Poster

Does mod mean the same as remainder?

Also, I have never taken a programming class before so please excuse my lapse's of knowlage.

Yes mod returns the remainder from the division of its operands. For example,
10 mod 2 equals 0 because 2*5 equals 10, with 0 remainder. Another example,
5 mod 2 equals 1 because 2 goes into 5, 2 times with 1 remainder. Work it out on paper first and you will learn it better.

mrnutty 761 Senior Poster

Ok go ahead and get started. Just do it! That way you will learn more. And when we
will help you if you have any problems, you will understand the solution better. We're
not saying this because we are pricks( I speak for myself ), but give it a go first
before you ask for an answer, unless you want to pay me, then I'll do it in a couple of minutes no problem.

Depending on how urgent its needed, the price varies. But on a normal priority, I charge
about $50 an hour.

mrnutty 761 Senior Poster

>>how would i go about obtaining a single char from a string

Huh, I'm confused on what you want, you do know you can use string.operator[] to
access the individual characters right?

string str = "text";
char ch = str[0]; //ch equals 't'
char ch2 = str[ str.size()-1]; //ch2 equals 't';
mrnutty 761 Senior Poster

Why not just do it manually? It'l take less time than that way.

mrnutty 761 Senior Poster

You know if you haven't seen it, wiki has a article on it.
Padding is introduced, when you are done reading one image witdh. For example :

for(unsigned n = 0; n < m_bmpInfo.imgHeight; ++n){
	for(unsigned m = 0; m < m_bmpInfo.imgWidth; ++m){	
		//read in pixels
		imgFile.read( (char*) &rgb , sizeof(rgb) );
		std::swap(rgb.blue,rgb.red); 
		m_pixels.push_back( rgb );			
	}				
	imgFile.read(pad,padding); //read in padding	
}
mrnutty 761 Senior Poster

Here are some problems, link

mrnutty 761 Senior Poster

Ok go ahead and get started. Just do it! That way you will learn more. And when we
will help you if you have any problems, you will understand the solution better. We're
not saying this because we are pricks( I speak for myself ), but give it a go first
before you ask for an answer, unless you want to pay me, then I'll do it in a couple of minutes no problem.

mrnutty 761 Senior Poster

Padding is done with 4 bit alignment. Here is how I calculated padding for a bitmap
image :

int padding =  (m_bmpInfo.imgWidth % 4);
if(padding != 0) padding = 4 - padding; //if its multiple of 4, then no padding else padding
mrnutty 761 Senior Poster

Here are some hints to get you started :

1) Given a number n, n mod 10, always results in the last digit of n. For example :

//mod = %
12345 % 10 equals 5
101011 % 10 equals 1
9234 % 10 equals 4
1 % 10 equals 1
0 % 10 equals 0

Now you have that fact. Here is one more:

Given a number n > 9, n/10 removes the last digit of n. If n is a 1 digit number,
then the result is 0. For example :

123/10 equals 12 //removed 3
100/10 equals 10 //removed 0
5234/10 equals 523 //removed 4
1/10 equals 0 //removed 1

Now you can use those facts to get each digit of a number. For example :

define n equal to 104
n mod 10 equals 4 and save 4
let n = n / 10 //n now equals 10 , 4 was removed
n mod 10 equals 0 and save 0
let n = n / 10 //n now equals 1, 0 was removed
n mod 10 equals 1 and save 1
let n = n / 10 // n now equals 0
since n is 0 STOP;

//now the digits we saved, do stuff with them

All of that is assuming integer arithmetic.

mrnutty 761 Senior Poster

Do something like this :

enum MenuStatus{ PLAY , EXIT }; //add more stuff here if needed
MenuStatus mainMenu(){ /* menu code goes here */ }
int main(){
 while(mainMenu() != EXIT) continue;
 else { exitApp(); }
}
mrnutty 761 Senior Poster

here is some psuedo code:

declare var;
start Do Loop
  get input into var  
  if var is not equal to 0 then do stuff
  else just break out of the lop
end Do Loop if var equals 0;
mrnutty 761 Senior Poster

>>But why does it exclude a value when it stores black(See: The red part) It is stored as 00 00

First why does what exclude it?
Second how are you reading in your image?
Are you throwing just random numbers out there, or is there more of that red
numbers in between the RGB?

mrnutty 761 Senior Poster

So all chars to be possible are numbers (0x30 .. 0x39) only ?

Why only should chars be converted into integers, aren't they already integers (0x00 ... 0xff) internally?

-- tesu

Actually, I mis-read his post. Sorry.

iamthwee commented: Naughty, naught :) -2
mrnutty 761 Senior Poster

1)Find all C++ reserved keywords online.
2)Insert the reserved keywords in order into map.
3)Read in word by word from the text file
3.a) For each word check if it needed word exist in the map
3.a.1) If not then "forget about it"
3.a.2) If so then doStuff with it

mrnutty 761 Senior Poster

Is is possible to take an array full of characters and then make the characters into numbers ?

To convert from 1 char to an int just subtract '0' from it. For example :

char ch = '1';
int i = ch - '0'; //i = int(1);

So just apply that to the whole array.

mrnutty 761 Senior Poster

First, you need to learn how to read in bitmap images. Find a tutorial with that.
Then when you know how to read in a bitmap image. You should have an array of int
values, which represents the color of the pixels in the images. For example :

black = 0x000000
white = 0xFFFFFF
Red = 0xFF0000
Green = 0x00FF00
Blue = 0x0000FF

Then you need an algorithm to detect from the array of pixels if the bitmap image
is a primitive shape. First learn how to read in the bitmap images. And get back
and we'll try to figure an algorithm out for this interesting problem.

mrnutty 761 Senior Poster

You can prove this by giving just 1 simple example. No need for general proof, because
if it can't work for even 1 case, then its incorrect.