Infarction 503 Posting Virtuoso

If you're going to use C++ I/O, you might as well use the std::string class rather than a char*. And for reading in a whole line of input at a time, use getline(). For the database itself, a vector would probably be appropriate. You could do something like this (pseudo c++ code):

#include <vector>
#include <iostream>
#include <string>

int main()
{
  using namespace std;
  vector<string> stringDatabase;
  string input;
  while(true)
  {
     getline(cin, input, '\n'); // I forget the exact parameter order
    /* find where the string goes */
    /* put the string in the vector */
  }
  /* output the contents of the vector
}

Not sure how to handle the Ctrl-Z off-hand though...

Infarction 503 Posting Virtuoso

grin

Infarction 503 Posting Virtuoso

gripe

Infarction 503 Posting Virtuoso

In regards to overcomplicating things, an array or rather class specifically designed to handle both chars and ints is surely more complicated? If we use your code sample as an example?

Qutie possible. I'd say it's less complicated than using char*, but I think it gets subjective at that point. Using an array of integers seems like an acceptable solution unless the OP intended to store strings and numbers.

How's the microsoft job going? Have you started yet?

Not started yet. I'll start at the end of June, after I graduate and take a quick summer vacation ;)

Infarction 503 Posting Virtuoso

thats fine because your chainlaoding windows fron GRUB. What i meant is that if there is no GRUB windows has to be the first on the first

I guess it doesn't always have to be the first partition of the first drive then, eh? ;)

Anyways, I moved Kubuntu to another partition and tried installing Vista again with no success, so I'm just giving up on it. If it doesn't like being on Disk 0 Partition 1, well, too bad for me...

Infarction 503 Posting Virtuoso

grep

Infarction 503 Posting Virtuoso

It depends what you mean by char.

char crap;

or char crap[];

With the second example you can store 452 as a data value, and parse the integers out of it.

True, but now you've gone from storing int and char to storing char* with the overhead of marking which ones may need to later be converted to integers. No need to overcomplicate things... ;)

Infarction 503 Posting Virtuoso

kelp

Infarction 503 Posting Virtuoso

veal

Infarction 503 Posting Virtuoso

Don't really play games that much. The occasional DotA game or Starcraft with my roomates, but those are kinda rare even.

Infarction 503 Posting Virtuoso

shell

Infarction 503 Posting Virtuoso

windows has always required being the first primary partition on the first drive

May I present my counter-argument:

jimmy@tensai ~ $ sudo fdisk -l /dev/hda
Password:

Disk /dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14         263     2008125   82  Linux swap / Solaris
/dev/hda3             264        6489    50010345    7  HPFS/NTFS
/dev/hda4            6490       60801   436261140    5  Extended
/dev/hda5            6490       12715    50010313+  83  Linux
/dev/hda6           12716       60801   386250763+   7  HPFS/NTFS

WInXP ended up on hda3 because it requires a primary partition. hda5 houses FC6 (/dev/hdc1 has Kubuntu as well, though I'll probably just move it to hdc2 so I can put Vista on hdc1 ;))

Infarction 503 Posting Virtuoso

smote (past tense of smite?)

Infarction 503 Posting Virtuoso

funny, I think this is spam... very tricky though...


(it came up here as well)

Infarction 503 Posting Virtuoso

wants

Infarction 503 Posting Virtuoso

Nah store them as chars, I always do. ints are unsafe. If the user doesn't type in an int where the program expects an int, it crashes, whereas with chars you can't go wrong, if it's bad, you just discard the input and tell them to try again.

Believe me this is the easiest way.

It depends on where the data is coming from. If it is coming from an input stream, there should be handling in place for the event of bad input. Even if you treat it all as characters, you'll have to parse numbers out of it anyways (unless you're only keeping single-digit ints). What if I do want to store 452 as a data value, assuming that it is valid input? Using a char, that would break your code.

Easiest isn't always best.

Infarction 503 Posting Virtuoso

print

Infarction 503 Posting Virtuoso

on ubuntu you enter your user password and su and root login are disabled

yes, no, yes. User password is all sudo needs, on any system I've used. Root login is disabled by default on Ubuntu. BUT, su is not disabled. Try running sudo su. Try to su to another user's account (that's what it's for, afterall), even without sudo. su still works just fine. (Actually, that was how I checked that users aren't added to admin by default - useradd newUser, su -l newUser, groups).

Infarction 503 Posting Virtuoso

Would you mind posting the solution, just for if someone reads the thread later? (And I'm remotely curious as to how to do it as well ;))

Infarction 503 Posting Virtuoso

LF or newline is a character which belongs to the ASCII character set. Is priting out characters using streams non portable ? Cit any one situation which showcases its non portability....

Newlines on some systems are done with \r, \n, or \r\n (I forget which goes with which). Hence, non-portable.

Infarction 503 Posting Virtuoso

No just store them as characters, then if need be convert them to ints.

I'd go the other way (int to char) so you don't lose data if the int value is >= 256...

Infarction 503 Posting Virtuoso

Not in a simple way. Because things are strongly typed in C/C++, you need to have a single type that can hold your data. You could do something along the lines of this though (pseudocode):

class Data {};
class Int : Data {public: int i};
class Char : Data { public: char c};
Data* theArray[someSize];
theArray[0] = new Int; 
theArray[1] = new Char;
Infarction 503 Posting Virtuoso

in order to use the sudo command, you DO need the root password.

Funny, I've never needed it...

Infarction 503 Posting Virtuoso

string

Infarction 503 Posting Virtuoso

I was trying to install Vista onto a spare partition yesterday, and the installer refused to use the partition. I deleted it, formatted it, tried again, no go. Deleted it, made it bigger, repeat, no go. I was using the 3rd partition on the drive (still a primary though) but I was wondering if Vista requires itself to be on the first partition? Any ideas?

(Partition sizes I tried using were 50GB and 90GB)

Infarction 503 Posting Virtuoso

thor

Infarction 503 Posting Virtuoso

skype

Infarction 503 Posting Virtuoso

but on ubuntu server many admins will set up SSH which by default isnt configured to allow root login or SU but does allow sudoing from a remote localtion - thats bad security as anyone who cracks any account on a ubuntu server could get superuser access

That sounds more like a poorly configured system. Only trusted users should be in whichever group is given sudo permissions (apparently group admin on Ubuntu). By default, only the first user is added to this group anyways, which is expected (most OSs will have the first user be an admin; on most *nix it's root, but Ubuntu does it different). And sudo is configurable if you want to make sure nobody is touching certain things...

Infarction 503 Posting Virtuoso

chip

Infarction 503 Posting Virtuoso

Not quite sure what you mean. Boot Camp is only for Windows, and booting with Linux with/without Windows is best done with rEFIt. Which can handle several (not sure of the limit) OSs.

Unless of course you meant support for booting both Windows XP and Windows Vista...

Ah, didn't realize Bootcamp was for Windows only.

Infarction 503 Posting Virtuoso

- not being bound to proprietary hardware
- bootcamp having support for >2 OSs (I've heard it doesn't)

If it weren't for that, I might buy it :p

Infarction 503 Posting Virtuoso

i hate ubuntu server
sudo on a server is dumb it teaches bad practice

Why exactly is sudo so bad? It seems to me like the usual FUD people throw around with goto statements...

Infarction 503 Posting Virtuoso
Infarction 503 Posting Virtuoso

^ is a bitwise XOR operator. It can only be used on primitive integer types.

?: is the ternary operator, so named because it takes three parts (see example below). It's shorthand for an if-else clause.

if(condition)
  foo();
else
  bar();
// can also be done as:
condition ? foo() : bar();
Infarction 503 Posting Virtuoso

I got 1, 3, and an alternate for 6 (Christmas Eve, Christmas, Boxing Day).

Infarction 503 Posting Virtuoso

I do not actually really believe that most people feel that Valentine's Day is a false-hearted day, a commecrialized event only. Everything practically is commercialized these days so of course this will be to, correct? The real culprit for this case and topic of holidays to avoid is Christmas; I am a Christian and I am bloody disgusted by the American Christmas, honestly.

Definitely agree re: Christmas.

Valentine's Day gives people the chance to express their love if only for one day and it provides the memory and hopes for love if one is single at the time. This is sad in a way, I know, as love is spread everday for sure, but many people do not feel this way nor know how to exactly do this. Men, especially, are not very romantic as far as I can tell. But I am and it is a lovely holiday for those who dig it. Plus, pink is my favorite color so this Holiday makes me happy because of that and because I have a lovely woman to share this day with. Then again, everyday is Valentine's Day for us.

The last sentence is great. I wish it was like that for everyone. But I do think that the whole roses+chocolate+dinner+jewelry is a little excessive. Not that they're bad by any means, but the holiday shouldn't be about those things.

mattyd commented: good thoughts -thanx\ mattyd +2
Infarction 503 Posting Virtuoso

It seems like the vast majority (87% at the moment) dislike or can live without this holiday. Funny, isn't it?

I think it's become another compulsive commercialized scam. For one, it shouldn't take a holiday to tell someone you love them, nor should it take expensive gifts on said holiday. Two, in many places around the world, Valentine's Day really is nothing more than something advertized by companies interested in making a larger profit; there's no cultural background for it, but people just go along with it to spend money. Three, think of the mental repercussions (traumatic perhaps) on all those poor single guys out there... maybe a class-action lawsuit is in order... :twisted:

what day is valentines day again? - the 14th or 16th

my birthday is the 15th

It's the 14th, the day after my sister's b-day. :p

Infarction 503 Posting Virtuoso

Though I am no expert on Mathematics, but the article says that Ackermann function can also be expressed iteratively and if it can be expressed iteratively, it can be solved iteratively.

Here's what it said:

The Ackermann function can also be expressed nonrecursively using Conway chained arrow notation:

As with most combinatorial symbologies, the definition is recursive.

Infarction 503 Posting Virtuoso

Just a brief look through the API (starting from JFrame's setDefaultCloseOperation()) took me to WindowListener, which might be what you're looking for.

Infarction 503 Posting Virtuoso

...which even can be solved with a really simple loop.

The Fibonnacci sequence is defined as a recursive equation; adding memoization and making it iterative makes the calculaiton much faster. So yes, it can be solved with a loop. Any simple recursive function can. The reason I brough up stable matching as being non-recursive is because I've never encountered a recursive solution for it; for instance, the Gale-Shapley algorithm is typically presented just as a loop.

Since the langugages in which we program are normally turing complete, there is as such nothing which can only be solved using recursion.

With the very notable exception of functional languages which use recursion as their way of creating an iterative procedure. And I don't know for sure, but I don't think you can calculate the Ackermann function iteratively.

Infarction 503 Posting Virtuoso

Didn't really look at your code, nor do I intend to, but I'll propose a few methods for breaking out of nested loops:
- LIke WaltP suggested, use a variable as a break condition. Check it in your loop condition statement or in an if statement at the end of the loop.
- use a goto. This can be dangerous if not done properly. But it can also be the easiest way to get the job done. If you can't think of why it could be bad, it's likely you shouldn't use it. If you know what the problems with using a goto are, but you've decided your specific code segment is safe, go for it.
- similar to above, but use an exception instead. There are some similar consequences if you're not neat about it (e.g. if you have some dynamic allocation inside the loop, it won't be deleted unless you do that when you handle the exception). Still a little more safe than a goto though.

The last two will probably receive some criticism, but they are possible ways of solving the problem.

Infarction 503 Posting Virtuoso

lol that was funny. :D

Infarction 503 Posting Virtuoso

Google for terms like Sierpinski curve, Knights tour, Travelling salesman problem, Stable Marriage problem and the Eight Queens problem for some applications of recursive problem solving techniques.

I'd take stable-matching/marriage off that list, since it's much easier to do in a loop. Min-max would be a suitable replacement, however, it might be too complex for a basic example.

@OP: recursivity is a useful tool for breaking down problems and handling them in a divide-and-conquer fashion. This won't always yield a more efficent result, but in some cases it does. The basic premise of recursion is that a function calls itself with a subset of its data, and solves a problem for that subset. When the 2nd call returns, the data may require some extra manipulation; other times, it'll have been handled during the recursive call anyways (see mergesort and quicksort respectively). As mentioned earlier, the FIbonnacci sequence is a classic example of recursion.

mattyd commented: recursivity help-- thankyou-- mattyd +2
Infarction 503 Posting Virtuoso

Holy thread necromancy, Batman!

Sorry, just been wanting to use that line for a few days...

I guess I don't qualify as an old-timer... *whistles*

Infarction 503 Posting Virtuoso

What the hell is the Digital Millenium Copyright Act Anyway?

Some scandalous legislation I'm sure. Too lazy to wiki it.

supposedly things like libdvdcss are illegal in the U.S

Oops :twisted:

well im not in america thank you very much :(

You aren't but he probably is.

Infarction 503 Posting Virtuoso

...but this works fine...

It shouldn't. Your first code sample should die a fiery death (and it does). It's because when you have code like this:

char* c;
c = "some string in memory";

you're just changing where the pointer c points to. It really points to some random place in memory. When you do something like

char* d;
d = new char[someLength];

you're allocating some specific memory, then pointing d at it. This has repercussions, since if you change the value of d you won't have a pointer to your allocated memory (unless of course, you've copied the address to another variable). In order to prevent your program from leaking the dynamically allocated memory, you have to delete it. Here's the tricky part - if you delete memory that wasn't dynamically allocated (like the first code segment), things go boom. That's the problem your code has.

As a side note, you should never call a destructor. It happens when the object goes out of scope or (if it's dynamically allocated) when it's deleted.

Infarction 503 Posting Virtuoso

for the original problems, the answers should be 20 and 256. Since it's a loop, it'll repeat until the condition is false (i.e. until a>12 and a>25 respectively).

Nick Evan commented: Good catch, totally missed it.... -Niek E +1
Infarction 503 Posting Virtuoso

Next in priority is my dvd player. I'm thinking i need codecs from the net is it oggle i need?

I use VLC for pretty much all my video needs, and it seems to handle everything fine. Comes with almost all the codecs you'll ever need...

Infarction 503 Posting Virtuoso

My grandma has horrible luck with computers, too. She's always had a Mac and I've never had one, so I just claimed I didn't know how to fix them (mostly a true statement anyways). So she consistently takes it to my aunt and uncle, who also have several Macs. Apparently my grandma has a habit of cleaning up her hard drive by deleting any file she doesn't recognize... including system files. :mad:

Infarction 503 Posting Virtuoso

Not till you've understood the forum rules