~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are under the misconception that GUI programming implies placement of various graphical components. Its not that simple. For placing Graphical components, you can always use IDE's which offer the feature of drag and drop. GUI programming brings with it concepts like events, multi threading and what not.

And the ones you are referring to are called GUI designers, not GUI programmers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> he's not talking about threading im sure.
For a small scale project, yes, but for real games, multi threading is what he is looking for. Games almost always make use of multi threading.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use BufferedReader (1.4) class to read in each line of the file as a string and for each line, locate the position of the '=' character. Use the substring function to extract the left and right parts of the string based on the position you have got. Skip the lines which don't contain an '=' character.

This is as simple as it gets although you might need to throw in a bit of additional logic depending on the kind of output you need.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Assuming your palindrome logic ignores case, here is one solution:

String str = "AB , ba";
StringBuffer sb = new StringBuffer(str).reverse();
String strRev = sb.toString();
if(str.equalsIgnoreCase(strRev))
    System.out.println("Palindrome");
else
    System.out.println("Not a Palindrome");
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please use proper punctuation and formatting, your posts are difficult to read. Also please don't use l337 speak.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMHO, C++ is not exactly an ideal language for someone starting out with programming. Starting out with Python would be more like it. Once you start getting a hang of how things work, jumping on to C/C++ would be more rewarding. Not to mention Python makes it easier for one to develop GUI applications -- easier than C++.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I can fairly bet that the zero initialization done when declaring static variables internally uses memset to achieve its objective. And I really wonder how making 'output' a static variable would help between function calls. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> In other words, it's not man's own aptitude that allows him to do this
Correct.
> it is God's power through him.
Everyone has different names for it. Some call it inner strength, some call it power of love, some call it power of hate, you call it God. Fair enough.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Well yes, to people who don't believe it is simply a story. Just like everything else in the bible.
If one has strong belief, one doesn't need XXX to part the valley of water. He can do it himself.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Amen to that. I completely agree that reputation is no measure of your helpfulness.

According to me, Salem is the most reputable person around, considering that I haven't seen his single post out of the C / C++ forum -- in short hard earned, well deserved reputation.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

And just a passing thought, I would stay away from using 'string' as a variable name. Converting that program from C to C++ would be a maintenance headache.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> it really annoying that i still only have 1
Start contributing, they would automatically grow.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Reading this thread thoroughly might give you some link...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Aia, the above solution is overly complicated, not to mention doesn't work. Its always recommended to initialize the char array to '\0' and not to use gets().

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> well i was gunna ask about when moses parted the valley of water
> in the story when he freed everyone, how is that possible?
Its a story, thats why its possible.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The search results are thrown at you based on popularity (also called as page rank) and there is no doubt Wikipedia has lots of it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Unless put through some rigorous testing and profiling tools, the performance difference between the algorithms proposed so far is insignificant.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The usual "this doesn't work" is not helpful at all. You need to tell us 'what' is not working and what you have tried out. Post the most recent relevant code which shows the concerned logic and then we can work out something.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

<sarcasm>
No please don't stop yet. You have come really far people, lets post some more random things about God and make this thread one with 100 pages(currently its 99).
</sarcasm>

;-)

Aia commented: <sarcasm> The best is to come </sarcasm> +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How about something like: imageId = imageArray.length % dayOfMonth; Change the formula to suit your needs but I hope you get the logic right.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Jwenting is right, put that code in a servlet. And not to mention if "eid" is the primary key of your "lang" table, you end up overwriting values.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You forgot to do:

if(rs.next())
{
//your code which uses rs
}

You got to realize that unless you do a next on the recordset, it isn't actually pointing to anything, this is because the implicit cursor in any kind of database always points to the nothingness.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Why not Eclipse ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Lab test and the Cat scan..
Hehe.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No, because it never reached the ground... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess no. Create a thread on PC games and you will have many takers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Those are great, esp the 'expand' and the 'find x' one. Keep up the good work and keep them coming Arjun since 'we need to laugh'. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use third party API's if you want your application to be platform independent or use the Win32 API if programming under windows. If using Windows, using C# would be more like it if there is no compulsion on using Win32 API or MFC.

Here is one of those third party API.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> you can't imagine how annoying that is...
You bet we do, we have been here long enough... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

*updates his list*. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Size of data types is architecture dependent, not compiler. For long, it is 2 * word size of the machine. The compilers just follow the specification laid down. It would be nice if someone with a copy of C++ standard could confirm this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Well the one which I read is "Joel on Software". Not all, but still some of his blogs are really funny and informative. Other than that, a lot of Java blogs. :)

BTW, which RSS reader do you use ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hey, how come you get to be the center of attraction everytime? ;-)

Congratulations Davey. *thumbs up*

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thats it, this is as fast as it gets using my technique. Basically I reduced three calls to constructors and destructors respectively. ;-)

#include <iostream>
#include <cstring>
#include <stdexcept>
const size_t MAX_SIZE = 32; //some multiple of 8 greater than 10

using namespace std;

unsigned long extract_digits (unsigned long x, size_t n, size_t i)
{
    unsigned long result = 0;
    char* input = new char[MAX_SIZE];
    sprintf(input, "%lu", x);
    if(i >= strlen(input))
        throw runtime_error("OutOfBoundsException");

    char* output = new char[MAX_SIZE];
    memset(output, '\0', MAX_SIZE); //necessary to wipe the junk
    strncpy(output, input + i, n);
    sscanf(output, "%lu", &result); //can be replaced with strtoul()

    delete[] input;
    delete[] output;

    return result;
}
iamthwee commented: yes but it is bastardised c++. -2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

GetBackers is one of my favorites, kind of has a dark and funny feeling to it.

> I also watched 2 ep of xxxHolic
Don't bother with that one, all you would be left with after watching 10 eps is 'hopelessness'. One of those guys can see ghosts while the other can ward them off. Thats it. Better watch GhostBusters -- it is much more fun.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is the code expected to be HW/compiler independent ?
Standard C++ is always compiler independent.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I'd start with the basic model of s.o.s and add the following checks:
I have already added those.

> To make the function more secure I'd consider changing the
> function prototype and definition to accept only strings as input
This is a C++ challenge, so we are not allowed to change anything ;-)

Also, sending an unsigned long is not an error, its a subtle bug. You can't find out given a number has overflowed or not by any easy means. Plus the function I posted doesn't crash given the signed input since it would anyways be converted to unsigned one.

> he only microptimization I'd know to do would be to call str.size()
> only once, not three times, in extract_digit().
Huh, three times ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since the specifications were not accurate, I made some assumptions when it came to exceptions. Being a Java programmer I couldn't resist this humble solution...

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

unsigned long extract_digits (unsigned long x, size_t n, size_t i)
{
    stringstream ss;
    unsigned long result = 0;
    string output;
    ss << x;
    string str = ss.str();

    if(i >= str.size() || i < 0)
        throw runtime_error("OutOfBoundsException");
    if(n < 1)
        throw runtime_error("NoDigitsSelectedException");
    output = str.substr(i, n);
    ss.str(output);
    ss >> result;
    return result;
}

int main(void)
{
    cout << extract_digits(234324, 3, 3);
    cin.get();
    return 0;
}

I guess I satisfied both conditions I and II of the problem statement though I am a bit unclear of what the third meant, considering that this would work for really long numbers without getting into the powers of 10 stuff.

PS: I hope I get a prize for this, I am in real need of some cash rewards. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Asking in the appropriate forum would be more like it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Then turn back. I'm leaving now.
I am surprised Dave that an old timer like you, who must be definitely having his share of posts of forums which didn't even have code tags, be so attached to colors. I have seen the best of your posts not rely on some coloring to deliver its value, so I guess there is much more than it meets the eye.

> I really do want to do what's best for everyone. Honest I do.
I guess this is the price one must pay for being cooperative and trying to mingle, considering that I have seen forums run by Nazi admins who don't give a damn to anything.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I'm just as "mean" to other people as I am to you, so don't feel like you're being singled out.
Good thing moderators are outside the 'mean' domain ;-)

> But I clearly understand, I'm stupid. I'm done.
You have just started out in your life. Like Narue previously said, these things do and will happen. Running away won't solve your problems, face them, fight them. Good luck.

arjunsasidharan commented: That's what i said big B :) +2
Rashakil Fol commented: To gain, you must lose something of equal value. -1
Aia commented: You are gaining. +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> And EVERYTIME I bad rep someone for a good reason over something, WolfPack "equalizes"
Actually someone goes out and equalizes any kind of bad rep given ot anyone, and even I try that out. Didn't I give that to 'sk8ndestroy' ? Didn't I give it out to you ? And I guess considering that me, wolfpack and the others can go a long way in influencing someone's rep (almost 10-20 points) I don't see any problem even if you get bad repped by 2-3 normal posters.

<something here to keep things on topic which is basically how off topic I can go>

christina>you commented: yes, you are right. +9
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> You obviously don't use MSN Messenger
Rightly said, I normally don't use messengers but if necessary, Yahoo is the one I go for. And being a proponent of text based smileys, I don't know a lot about the modern ones.

> I can even see the rose petals in (F).
Ah, the kind of imagination you possess. ;-)

WolfPack commented: he he +7
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Did you try it alrdy?
No, I haven't as such any practical experience with server development, just a bit of knowledge about servers here and there.

> Isnt it bad having like 1000 threads opened at same time?
Its better than having 1000 processes running at the same time. Clients have to be serviced -- threads or processes, take your pick. And believe me, they don't call threads lightweight processes for no reason.

> I dint tell much about the server... it ll be a game server, basicly accepting conections, receveing data, sending and compute the game stuff.

There must be a ready made open source server floating on around somewhere, you just need to look hard for it. But since you have already achieved a lot, good luck.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Variety of topics
All of them being offtopic... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not PHP, its basically used for generating dynamic content. Developing a full fledged server is not something it was made for. C# yes possible but most of them are made in C++ and Java.

As for the threads, the idea of the web server running with just one thread is plain crazy. You need to accept requests along with servicing them at the same time returning responses. Plus spawning a new thread for each request is much more recommended than creating a process for each client request(the way it is done in JSP and Servlets). Starting from scratch would be kind of a daunting task. Take a look at some of the open source web servers written in C++ to get a gist of how things are done.

> Thats why i made this post... to now what ppl think that would be the fastest way.

The fastest way would be to use an existing server or build up on its functionality if you require customized features.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Flying off into outer space in between a cloud of debris with no
> space suit isn't something you forget for the rest of your life.

Huh? What was that?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

<offtopic-rant>

I would change the world but God didn't publish the source code..

Smart people can always reverse engineer it... ;-)
</offtopic-rant>

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Good one... ;-)