Killer_Typo 82 Master Poster

I think it means the author of the book was tired and miss-typed :)

Killer_Typo 82 Master Poster

yes when you call any accessing elements of an image the image is loaded at that time.

If you were to say create a new Image on "/myImage.jpg" and then call image.getWidth() it will return -1 until the image has been loaded.

Try this out in debug, call image.getWidth() and debug that line, if you call it again after a second or so (probably less, but it's a decent enough buffer) the image will finally be loaded.

It's an asynchronous process so that you don't go new Image("some massssssive image") and end up waiting a long time for it to display.

Using ImageBuffers and MediaTrackers are great alternatives since you can get the images immediately. These also allow for smarter handling of the images, which is really what most people want.

Killer_Typo 82 Master Poster

Using a MediaTracker is definitely a good idea: a MediaTracker will allow you to pre-load images on a loading screen and bypass any issues you may encounter with loading images on the fly - such as awkward display issues and not being able to get dimensional information on the image until after it has been drawn to the canvas.

Killer_Typo 82 Master Poster

Programming is not just something you do, it is a passion. If programming is not a passion you are not going to find a magic pill or answer that will get you on track.

In 10 years if you feel you haven't gained much then you should assess why you are doing it in the first place.

Part of the problem with coding is that it's easy to lose focus and never finish a product. A lot goes into creating the perfect application, that one sweet bit o code that when all compiled together makes your pants fit just a little bit tighter.

Spend some time researching what you want to do and dedicate yourself to it. Get yourself hyped up and psyched out. You want to be passionate about whatever you are creating or it will show in the work (lack luster results). You need a clear plan of attack, from what the program is, down to how it will work.

You need to think about:
User Experience
User Interface
What the program does
How the program does it

Component-ize your work, set clear goals and meet them. Don't just say, "I want to create a video game" and get frustrated when you don't meet the goal, that goal is too generic and doesn't really allow you to feel the fruits of your labor.

Example:
"I want to create a side scroller like mario"
What should the …

Gribouillis commented: great +13
Killer_Typo 82 Master Poster

In the android environment all files are created in MODE_PRIVATE!

Each application is run by its own user: any files created by an application can only be accessed by that particular application. Setting MODE_PRIVATE to the file is simply an option available as you can set files to be public-accessible.

However, if a user has root access to their phone they can CHMOD or simply pull the file off of the device. From an applications perspective, this is unlikely to happen as they would have to know the package namespace (com.google.etc.yourapplication) of another application as well as have the proper system access to change file permissions for which it does not have access - which is a permission reserved for ROOT and I believe applications are run as regular users and not root users.

Killer_Typo 82 Master Poster

http://www.eapps.com/

I've used them for quite some time, good pricing and a TON of control over the server. Great service and a ton of FAQ documentation to cover some of the various tasks one would setup: Tomcat, Glassfish, SSH, SFTP...etc

Killer_Typo 82 Master Poster

when I graduated from college I wrote a multi-threaded database administration tool. Has lots of use if you cover more than just a SQL entry pane. If you include functionality like, creating, removing, updating, adjusting tables...etc

Killer_Typo 82 Master Poster

>I found the best book to be google
Yes but sometimes you need a flow to what you are reading which is hard to get given the fact that you are looking up different articles written by different authors scattered all over the internet.
Also when you read different articles by different authors you would sometimes find them contradicting each other a bit, because every author has hos own style, his beliefs his own "best practices" etc,
I am not saying that this isn't a good way, yes it is, but for a beginner not a preferred way to begin with.

as a beginner my first C++ book was a C++ primer that covered basic loops and pointers, I know pretty much dig through google for the rest. WHile many articles can seem to contradict eachother it evens itself out in the end. Nothing wrong with a large amount of code exposure. In my experience I have found pocket references and super thin primer style books to be the best. Heck - even a Java Spark CHart rocks, it's straight to the point and easy to follow. It's only 2 pages :P

I may be an exception to the rule, but I find books to be better suited as a backup. The books I prefer to keep in my library are cook books and pocket references who knows, maybe I am just a bit weird ;)

>Given a good compiler (NetBeans or Eclipse)
These …

Killer_Typo 82 Master Poster

I found the best book to be google and the best tutorials to be whatever the mind can conceptualize into the digital world.

I have been writing software since the 6th grade (C++ and Java more recently) and I must say I learned the most when I took every day computing tasks and wrote applications to solve the problems.

Java is a very neat language in that you can very easily get up and running with it given you've got the time and patience to do so (almost contradictory I know haha :P )

Given a good compiler (NetBeans or Eclipse) you can begin serving JSP and servlet based applications almost immediately and can go spiraling up from there.

So to make a long bloated story short, find something you like to do on your computer or something you find boring enough - and write a solution to it.

I started with files manipulation: moving files, searching for content, manipulating contents...etc and progressed from there. I've since dived into servlet applications, image meta data manipulation, service bus implementations, student loan calculators, database administration applications, multi-threaded apps, web sniffers / harvesters...etc

You never know where the fingers will take you :)

Killer_Typo 82 Master Poster

.NET only works on windows and you need to use Visual Studio for it

you dont need to use the visual studio environment for .NET but it sure does make coding a hell of a lot easier :P

Killer_Typo 82 Master Poster

I use Microsoft Visual Studio Professional

if you are just starting out i would recommend the express versions.

I've dabbled around in other IDEs and with other compilers but i happen to like the MS Vis-studio IDE /Compiler the best.

The MSDN Library microsoft offers is very compiled as well.

Microsoft all around has taken very good care of it's programmers.

Killer_Typo 82 Master Poster

Aside from the major syntax and naming issues:

thats because your array of 20 looks like

Rudolf00000000000000
--------------------

// each 0 is actually a null character

where as the array you specify looks like this

Rudolf
------
Killer_Typo 82 Master Poster

check out http://support.microsoft.com/kb/319257

it really should be as simple as Console.Clear()

Killer_Typo 82 Master Poster

hi, thanks for your reply.............is it really that simple? Thanks

why not give it a shot ;)

System.Console.WriteLine("hello world");
System.Console.clear();
System.Console.WriteLine("Hello world again");

give it a shot.

Killer_Typo 82 Master Poster

System.Console.Clear();

Killer_Typo 82 Master Poster

thanks for your answer,


my mistake, yes the code compiles but the 3 statements have different bahaviours....


yes, but according to this

//Program creates char d, sets it equal to lowercase letter
//Converts it to uppercase and outputs it
#include <cctype>
#include <iostream>
 
using namespace std;
 
int main()
{
    char d='a';  
    d=toupper(d);
    cout<<d;
}

it should print the character not its ascii value.... I found the code here...

this statement is entirely different from what you have in your code.

/* 
toupper returns an INT value
toupper(a) will return 65 the ascii value for an uppercase A
*/

// the following statement will output the ascii value for the character
cout << toupper(a);

// the following statement will cast the INT value to the equivalent CHAR value
cout << (char) toupper(a);

Notice how i had to cast the output from the toupper function to char to get the character output.

By default the return type of toupper is INT not CHAR so to output the results directly will output an integer value not the character equivalent.

The reason your code works (whether or not it throws a warning) is because there exists an implicit cast from INT to CHAR.

So a user can create a CHAR and assign an int value to it.

/* for the following examples the compiler will automagically cast the INT values to CHAR without the use of an explicit cast*/
char mychar = 65;
cout …
n.aggel commented: thanks! +1
Killer_Typo 82 Master Poster

your code worked and compiled fine for me (besides a typo in your post)

what exactly are you referring to as not working?

cout<<toupper(*pos)<<" "; //without cast it doesn't work, why?

while it does work the output from it may not be what you are expecting. the output from toupper is int not char, so when it is cout'ed the result is going to the ascii equivalent for the character.

*pos=toupper(*pos); //and this also doesn't work
cout<<*pos<<" ";

*pos is pointing to the character that the iterator is on (my wild guess) so it can be cast back to char without an explicit cast.

but it compiles and runs fine on my end :)

but if you are wondering my output from running this:

A 65 A
B 66 B
C 67 C
. .. .
Y 89 Y
Z 90 Z
Killer_Typo 82 Master Poster

Here is a version I wrote based on your code and heavily commented :)

#include <iostream>
#include <fstream>
using namespace std;
int main( void )
{
 ifstream inFile;   // create a file reader
 inFile.open("vowels.txt"); // open the vowels.txt file
 char ch = '\0';    // holds each letter for testing
 int numz = 0;    // number of vowels counted
 
 // get the string from the file specified
 if (inFile.is_open())
 {
  while (inFile.read(&ch, 1))
  {
   cout << ch; // output the character
   switch (tolower(ch)) // test the character
   {
   case 'a': case 'e': case 'i': case 'o': case 'u': // what about sometimes Y too?
    numz++; // incriment the counter
    break; // stop the switch
   }
  }
  cout << endl; // close off the sentence
  inFile.close(); // we are done reading the file close the stream
 } else {
  printf("Failed Opening Stream\n"); // oops we couldnt open the stream
 }
 // show the user the number of vowels
 printf("The number of vowels: %d\n", numz);
 cin.get(); // wait for user input before closing
 return 0;
}
Killer_Typo 82 Master Poster

Make sure to test if the stream is open

inFile.is_open()

if it's not open your vowels.txt file is in the wrong directory.

that being said if you want I can PM you a working version, a little simpler, but i will wait till you struggle through a bit more before posting it :P

either way you've made good progress.

EDIT:

please remember that HI HELLO would look different than Hi Hello, your current statement would not count the vowels in the first uppercase version.

Killer_Typo 82 Master Poster

yes it can be a bit of a pain at first but using the windows api it can be done :)

this is of course in windows, you need to specify the OS for a more specific answer.

http://msdn2.microsoft.com/en-us/library/ms632587.aspx

Killer_Typo 82 Master Poster

i did a google on the error you posted but didnt get much (put it in quotes to hope to find someone with the same error)

doing a little rearranging this was the best i could find

Memory Leaks


A memory leak is a loss of available memory space. This occurs when dynamic data are no longer needed in the program, but the memory that is used has not been deallocated. It can also occur when an assignment is made to a pointer variable that already holds the address of an allocated area.
Each time a memory leak occurs, the application drains the available memory pool. Even in virtual-memory systems, the gradual increase in application size can result in performance degradation that affects the entire system. Eventually, this performance degradation can lead to a fatal out-of-memory condition that may be encountered by an application unrelated to the one that caused the memory leak in the first place.
Tip: make sure you match allocation calls with deallocation calls when doing unit testing, particularly where there might be an early return from a function where dynamic data was allocated. It's also essential to check, before assigning to a pointer, that the memory accessible via that pointer is freed prior to the assignment or made accessible some other way.

Killer_Typo 82 Master Poster

post your code please :)

Killer_Typo 82 Master Poster

since you are using VC++ i am assuming you arein the .NET framework?

do you happen to be working with windows forms?

System::Windows::Forms

if so then you can capture keyboard input very easy on any form.

Killer_Typo 82 Master Poster

http://www.cplusplus.com/

great resource, i use it for the most part.

Killer_Typo 82 Master Poster

this thread is over two years old, please allow it to rest in peace.

Killer_Typo 82 Master Poster

The idea here is to make each character in the string exist in every position, for example:

string is "JOY"

so taking J:-
1st pass: "JOY"
2nd pass: "OJY"
3rd pass: "OYJ"

taking O:-
1st pass: "OJY"
2nd pass: "JOY"
3rd pass: "JYO"

taking Y:-
1st pass: "YOJ"
2nd pass: "JYO"
3rd pass: "JOY"

then remove the repeated results, and you'll get all the combinations for that string

great post.

actually gave me some ideas on how i would personally tackle this problem.

Killer_Typo 82 Master Poster

to get a random within a range

int min = 33;
int max = 127;
int range = (max - min) + 1;
 
//now generate some random numbers
int somerandomnum = min + (int)(range * rand() / (RAND_MAX + 1.0));
 
//method will always generate a random number within range
Killer_Typo 82 Master Poster

Thank you very much. Appreciated.

I think the function will reach to zero time on sunday. That is what it does. It does not change

But can you please suggest how can I make this function more efficient as it is not very efficient with the use of too many while loops.

the most efficient method is going to entail determining the difference between what you have and what zero is and then subtracting by that ammount instead of continually removing one unit at a time.

so if you have 42 seconds instead of just removing one remove 42

if you have 39 minutes instead of just removing one minute at a time remove all 39.

this completely eliminates the while statements.

Killer_Typo 82 Master Poster

Wrtie the "itr = strv.begin();" after the cout...

I think when you initialize itr = strv.begin(); at the beginning of the code the itr points a random value at memory and when cout attempts to write this value it causes an error.

But when you initialize the "itr" after the loop, the "itr" points the first user defined element in the list and when cout attempts to output this value it doesn't cause an error...

you are correct in that it fails if you assign the itterator before you have placed any values into the vector.

Killer_Typo 82 Master Poster

found the second bug

while( str_time.substr(14,2) != "00")
{           
    str_time = format_time( input_time );
    input_time -= 60;
}

the reason this is incorrect is because the output time is formatted before the new time has been calculated thus the str_time format time will always be incorrect. the loop would continually get stuck forever.