Freaky_Chris 299 Master Poster

In reply to your question bangor boy,

public void showFeelings(int howManyGoals)
{        
    switch (howManyGoals) 
    {
        case 0: case 1: case 2: System.out.println("Oh dear, not very good"); break;
        case 3: case 4: case 5: System.out.println("Ive seen donkeys shoot better"); break;

            //and so on
     }
}

Also why is your name Bangor boy, are you at Bangor, Wales or perhaps Bangors, Ireland?

Chris

Freaky_Chris 299 Master Poster

@tintin,

Recommending the use of a recursive solution is rather an obscure method of helping someone out. Since everyone knows that a recursive function isn't exactly the most efficient solution by any means, although in normally provides a neater looking solution that is easier to code. 99 times out of 100 they turn out to be resource hungry machines.

Chris

Ancient Dragon commented: Yup +27
Freaky_Chris 299 Master Poster
output+= String.format("%1$10d%2$10.0f%3$10d%4$10.0f\n", i, QQ, d, inventory);
alisneaky commented: Love your work.i figured it out by studying what you gave me..thanx heaps +0
Freaky_Chris 299 Master Poster
JFileChooser jfc = new JFileChooser();
jfc.setDialogTitle("My Title");

Chris

Freaky_Chris 299 Master Poster

@CppBuilder

I'd recommend getting an upto date compiler. You might find that they work properly then ;)

Freaky_Chris 299 Master Poster

Please don't drag up 2 year old threads. And it should be noted that in standard C++ no there is not a way.

Chris

Freaky_Chris 299 Master Poster

Firstly, don't use sysrtem. use the function given to you by AncientDragon.

Secondly for an example, read the page it has a link to one.
Thirdly, that page tells you what parameters are needed, what they could be and what they do. Also it tells you what headers you need etc.

Please read information when someone points you to it, they don't do it for fun. They do it to try and help.

Chris

Freaky_Chris 299 Master Poster

Please note, we will not provide code solutions for you, you will need to do some work yourself and show evidence of the fact you have done so.

It's really not to hard, if you know some basic file handling techniques you can do it no problem.
It can get a bit more advanced but to start with it's simple enough, and I'm sure if you do some research; it would be even easier.

Chris

Freaky_Chris 299 Master Poster

Also it should be int main and return 0 :)

Chris

Alibeg commented: His posts were quite helpful, yeah :D +1
Freaky_Chris 299 Master Poster

The print statement in python (except python 3) automatically adds a newline at the end.

Should be noted that this can be prevent by doing the following

print "Hello World",

Yup a trailing ','
:)

Chris

Freaky_Chris 299 Master Poster
#include<iostream>

using namespace std;

int main(int argc, char** argv){

	int num, i;
	char** a;

	cout<< "how many strings? ";
	cin>> num;
	a = new char*[num];

	for(i=0;i<num;i++){
	        a[i] = new char[80];
		cout<< "enter a string: ";
		cin>> a[i];
	}

	for(i=0;i<num;i++)
		cout<< "string "<< i<< ": "<< a[i]<< endl;

	return 0;
}
Comatose commented: Beat me to it... very quick :) +10
Freaky_Chris 299 Master Poster
encryptedLine += (line.at(pos) + password.at(pos2));

if (pos2 > password.size())  {
	pos2 = 0;
}

You try to retreive the value at pos2 when pos2 is > than password.size() before you reset pos2 to 0. Also the check should be >= or == since if the length of string is 12, then the pos2 will need to be 13 to reset, yet you only get 0...11 index on your string.

Chris

Freaky_Chris 299 Master Poster

A) We do not do work for you.
B) Do not use "Fakse" Signatures
C) Do not advertise
D) Read the forum rules
E) Come back after doing these with a code attempt.

Chris

Comatose commented: Exactly +10
Freaky_Chris 299 Master Poster
void *malloc ( size_t size );

This is the function prototype, and as Agni stated it returns a void pointer. Since this is the function prototype you do not use this syntax when calling the function and infact you use the syntax you originally posted. Here is a small example

int q = 34;
char *test;
test = (char*)malloc(q);
...
free( test );

The snippet above will create a character array (c-string) of length 33, since 1 space is need for the null terminator. Be sure to read about the use of free(), it's essential!

Chris

Freaky_Chris 299 Master Poster
if(!inClientFile)

Please do not use this method, it is so wrong. You would be better using the following

if(!inClientFile.good())

Chris

Nick Evan commented: Holy s***, I completely missed that :( +12
Freaky_Chris 299 Master Poster

Read the forum rules, read a C++ book, read previous threads, just read something!

Chris

StuXYZ commented: lol @ "just read something" +5
Freaky_Chris 299 Master Poster

Solution has been sent to you ... however i didnt compile the code, but it will work, i just forgot to set the boundries of array and hope that u will do it by using a nested while loop of if condition, when u try yourself.

Have a happy programming :)

Please don't PM code solutions. I suggest re-reading the forums rules too. Just to make sure you understand how we work when it comes to handing out code.

Secondly, code solutions are best in the thread they are the solution for. So in the future people are able to search for solutions to problems and find it. Rather than having to start a new topic, waste more peoples time purely because some goon wouldn't share a solution.

Chris

Aia commented: Yes. +13
Freaky_Chris 299 Master Poster

So replace ".World" with ".Earth"
??

Chris

Freaky_Chris 299 Master Poster

Sounds like you actually want something like this....

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]){
    ifstream example("Exmaple.txt");
    string line;
    istringstream iss;
    vector<int> part1;
    vector<int> part2;
    int temp1, temp2;
    
    while(getline(example, line)){
                           line.replace(line.find(";"), 1, " ");
                           iss.clear();
                           iss.str(line);
                           iss >> temp1 >> temp2;
                           part1.push_back(temp1);
                           part2.push_back(temp2);
    }
    example.close();
    
    cout << "Part 1:" << endl;
    for(int i = 0; i < part1.size(); i++)
            cout << part1[i] << endl;

    cout << endl << "Part 2:" << endl;
    for(int i = 0; i < part2.size(); i++)
            cout << part2[i] << endl;
    
    return 0;
}
StuXYZ commented: tight clean code +4
Freaky_Chris 299 Master Poster

So

if(result > 99999) return 0;

*mumbles about multiple exit points*

Chris

Comatose commented: :) +9
Freaky_Chris 299 Master Poster

It should be noted that using ifstream with >> operator defaults to skipping whitespace characters, which '\n' is also included in. if you want to proccess the'\n' in a special manner then you should use the following loop condition while(fp1 >> noskipws >> ch) Not that you do not need to check eof, the >>operator returns false if it cannot read anymore chars...end of file. Also eof() can be trigger by certain control characters and hence should never be used to check for the end of the file

Also if you are after one line, I would recommend using getline(). Not only is it simpler, but it also faster. Reading multiple bytes from a file at once is faster than reading byte by byte

Chris

majesticmanish commented: He saved my life +1
Freaky_Chris 299 Master Poster

Guess what, there's only one person at this forum who is capable of getting the answer and thats YOU!

Chris

Sky Diploma commented: Good Answer ;) +1
Freaky_Chris 299 Master Poster

zalezog please don't add cin.get() to the end of people code snippets, they are not wrong by not using it. I would be more inclined to say you are wrong in using it.

Chris

StuXYZ commented: I really hate trailing get/pause etc. +3
Freaky_Chris 299 Master Poster
#include <iostream>
#include <windows.h>

using namespace std;

int main(void){
    bool updown = false;
    while(1){
        if(!updown){
            for(int x = 0; x < 100; x++){
                for(int y = 0; y < x; y++)
                    cout << endl;
             cout << "      .---.      "<< endl;
             cout << "     /__\\__\\     "<< endl;
             cout << ".---------------."<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "'---------------'"<< endl;
             Sleep(10);
             system("cls");
            }
            updown = !updown;
        }else{
            for(int x = 100; x > 0; x--){
                for(int y = 0; y < x; y++)
                    cout << endl;
             cout << "      .---.      "<< endl;
             cout << "     /__\__\     "<< endl;
             cout << ".---------------."<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "||      |      ||"<< endl;
             cout << "'---------------'"<< endl;
             Sleep(10);
             system("cls");
            }
            updown = !updown;
        }
    }
    return 0;
}

It's a bit broken but I'm …

Comatose commented: :) Nice +8
Freaky_Chris 299 Master Poster

Have a nice day!

Chris

StuXYZ commented: really nice use of urls / + generally good posts. +3
Freaky_Chris 299 Master Poster

On windows the following code will move the mouse cursor.

#include <windows.h>

int main(void){
  SetCursorPos(50, 50);
  return 0;
}

Of course you will want to play around with that. If you want more detail just ask

Chris

Freaky_Chris 299 Master Poster

can you not see the () on open? Its just you have two parameters inbetween them :P

You will need to escape that '\' characters
"C:\\programs\\fileneedschanges"
Then t shold work fine

Chris

Comatose commented: :) +8
Bladtman242 commented: well, it solved my problem +1
Freaky_Chris 299 Master Poster
ddanbe commented: There should be a template for your answer. +3
Freaky_Chris 299 Master Poster

thats the function prototype, it shows that the function has a return type of HWND andtakes two parameters. A HWND and an UINT. msdn then explains what each of the parameters are, it also lists all the possible options for the UINT uCmd and then it states what exactly is returned.

Chris

Comatose commented: Good Description, Clear... Concise. +8
Freaky_Chris 299 Master Poster

Well if you store all the information into a map, then could just call the map by the name...
http://www.cplusplus.com/reference/stl/map/

Chris

Freaky_Chris 299 Master Poster

I think your going to have to give more detail here...Are you using MFC? If so then a password box will automatically do this....

Again we really need more information

Chris

Salem commented: Yes we do :) +26
Freaky_Chris 299 Master Poster

I will take your advice, and improve it. But cut me some slack :icon_lol: ...
I made this when I was 14 I think, didn't seem too bad at the time. XD

As for the control key always being left on, I could never quite figure out why that was happening, the keyboard hook stopped windows from processing it. I will try Block Input though, hopefully this is still helping chrischavez solve his problem (as well as mine) :D .

You need to pass the ctrl key press with the KEYEVENTF_KEYUP flag. That way it wont *stick* so to speak.

I guess blocking input might be a bad idea since then you have no way of using the ctrl lol....there might be a way to sort it out. have a play with it i guess.

Chris

Freaky_Chris 299 Master Poster

that did absolutely nothing, but thanks for trying. I think the problem is that its not getting to the code for some reason maybe the while loop or something? i dunno but chris you prolly hit the code that said error cant open executable code.

Follow MosaicFuneral's Advice. the reason your program is terminating is due to the fact you have a vector of type string and you are trying to push an integer into it, see the problem?

Chris

Freaky_Chris 299 Master Poster

I think your missing the point. YOU haven't done ANY work....why the hell should we!

Chris

Salem commented: Why indeed! +25
Freaky_Chris 299 Master Poster

Please use code tags. These a thread related to them infact there all over the place!
Chris

mrboolf commented: Yeah no need to even bother opening the announcement - it's written right on top of the forum :-) +2
Freaky_Chris 299 Master Poster

Dear Ninwa
Thanks for your reply but still I can not write the whole coding structure which I needed.It doesn't make any sense to me.
I shoud be able to compile and run it in order to see how it works.
I would be very happy if you could write the codes from A to Z with detailed explanations.
Regards
ADAM

Not gonna happen this is not your homework solution lounge.
It's a guidance forum!

Chris

Salem commented: Absolutely +25
Freaky_Chris 299 Master Poster

Rather than me explaining it, i'll give you something to look at and think about. try adding the following line into your code, just inside the second foor loop

cout << "D: " << d << " B: " << b << " (" << d+b << ")" << endl;

The go through the output and see how many add up to 4

Chris

StuXYZ commented: Elegant way of getting the org. poster to think! +2
Freaky_Chris 299 Master Poster

please use code tags, and avoid red text many people will be repelled by it!

define IS_STRING 1
define IS_CHARACTER 2
define IS_INTEGER 3
define IS_FLOAT 4

This is to make a it easy for you to understand, basically writing IS_STRING is exactly the same as writing 1.

bool DotReached=false;

Create a boolean value can have the value of true or false

if(Input.length()==1 && (Input[0]>'9' || Input[0]<'0'))

Checks to see if the input is only one char long, if so checks thats its bewteen 0 and 9. Otherwise it must be a Char, cannot be a floating point. If it is between 0 and 9 then it is a integer.

if((Input[x]>'9' || Input[x]<'0') && Input[x]!='.')
{input_type=IS_STRING; break;}

Checks to see if the character is between 0-9 or is a '.' if not then its a string and breaks the loop since we have no reason to carry on.

{if(!DotReached) DotReached=ture; else
{input_type=IS_STRING; break;}

Checks to see if Dotreached has been set, if it has and we are at this point again then we know its a string. If it hasn't then it could still be a floating point.

Chris

ninja_gs commented: Thk Yu Chris........U r Kind Enough to teach me.......I m Happy ....... +1
Freaky_Chris 299 Master Poster

My advice, do not use eof() it's counter productive. Instead do this.

while(getline(file, someString)){
//yourcode
}

Chris

iamthwee commented: Amen +17
Freaky_Chris 299 Master Poster

You need to look into operators,
You may find this useful
http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html

Chris

StuXYZ commented: Excellent link! +1
Freaky_Chris 299 Master Poster

Indeed, this statement is like a an if statment its equivelent would look something like this.

string myIF(int a){
    if(a > 0){
        return ", ";
    }else{
        return " ";
    }
}

Hope that makes sense
Chris

sid78669 commented: Superbly Explained!! +1
Freaky_Chris 299 Master Poster
Salem commented: Careful, that link might be a bit advanced for them ;) +24
Freaky_Chris 299 Master Poster

Thats because the stack will be empty so you need to check stack.isEmptyStack(), if its empty break out because its unbalanced, if its not empty continue on and check.

Chris

Freaky_Chris 299 Master Poster
Salem commented: Gotta love LMGFY :D +23
Freaky_Chris 299 Master Poster

Hmm thats odd. I did think about the SendKeys module but i wasn't sure if you wanted to use it or not.

Addressing your other issue, did you try using self.textCtrl2.SetInsertionPoint(self.textCtrl2.GetLastPosition()+1) , i cannot say as i've tried it but that should theoretically force it to scroll to the bottom.

Chris

lllllIllIlllI commented: Thanks for that +1
Freaky_Chris 299 Master Poster

I think that the problem is that section is a char array and you have
the problem that you have to convert them to integers first, otherwise they have their ascii value. e.g. 1 is 49 (I think)

So isolate the number part of section and convert to an integer/double and then add.

however, all of that is a guess, you will need to post a little more code, in particular the type definitions of track, section and answer. Additionally,
while you are looking at it does track become to big... i.e. bigger than the array section?

As an extention to this assumption, i want to add the following. Indeed the ascii Value '1' has the numerical value 49. Thus we are given a way to convert a character to its numerical value, by subtracting 48 or '0'.

However this will not solve all of your problems. You may find that strtol() & strtod() are helpful in what you are looking for (sting header) you may find that a more practical solution is to use stringstreams.

If you want more info on these just ask, but i would recomend having a read from google links. And also search Daniweb for string/char to int conversion.

Chris

Freaky_Chris 299 Master Poster

Read the file line by line, split it into tokens based on spaces, then convert the number token into a double from a string.

You may want to look at.

getline()
strtok()
strtod()

Hope that helps,
Chris

Niner710 commented: Thanks for the response. +1
Freaky_Chris 299 Master Poster

No there isn't and again no.
You would have to write your own. Search the forums its a VERY popular question.

It will turn up alot of material for you to look at, including recursive and non-recursive.

Chris

Freaky_Chris 299 Master Poster

Just to summerise incase you don't bother reading, which wouldn't supprise me.

1) We do NOT do homework
2) We WILL help if YOU provide proof of attempts
3) Show where you are stuck
4) Provide detailed information about your problem

Chris

Salem commented: Helping to get the message across +23
Freaky_Chris 299 Master Poster

It works. I just figured it out this past Sunday.. I am new to the programming world so my "style may not be too good..

Your using C syntax in a C++ forum....

Also use [code][/code] please

@OP
rounding it off can be done by adding 0.0005 etc which which ever number of zero's it requires

Chris