Infarction 503 Posting Virtuoso

Since you're using non-standard headers, I think most people will have a hard time running your code. And without proper indentation, they'll have a hard time reading it.

To see if I'm understanding the code correctly, I'll repost part of it with comments:

// don't know what the loop conditions are for...
for(j=360;j>=0;j=j-5) 
{
  for(i=450;i>=0;i=i-5)
  {
    {
      setcolor(4);
      setbkcolor(0);
      delay(50); // does this sleep for 50ms?
      pieslice(290,250,i,i--,100); // draw second hand
      setfillstyle(0,0);
      floodfill(290,250,0);
      circle(290,250,100);
      {
        delay(300); // sleep again?
        pieslice(290,250,j,j--,50); // draw minute hand
      }
    }
  }
}

The problem is that you'll draw the minute hand every time you draw the second hand. You need to move the innermost block into the outer for loop (after the inner loop), then possibly readjust your loop conditions. Pseudo-code:

for(/* ... */)
{
  for( /* ... */ )
  {
    /* whatever to draw second hand goes here */
  }
  /* whatever to draw minute hand goes here */
}

That way the minute hand only gets updated when the second hand has gone all the way around. For the hour hand, do something similar with yet another loop encompassing these. ;)

Infarction 503 Posting Virtuoso

Ah, you must be speaking of British English and not our Yankee, improved version. :lol:;)

Regards,
MattyD

Fixed ;)

Infarction 503 Posting Virtuoso

This looks a lot like homework, but what the hell....

3.As the Unix OS is entirely made up of C prog.language,is there any OS entirely made up of Java?

There was JavaOS by Sun, but it's already considered legacy. Pretty much a microkernel with a JVM looks like. There's also an open-source project JNode. So yes, it's possible. No, it's not common and likely never will be.

Infarction 503 Posting Virtuoso

linky
If that doesn't help, google around on how to use exceptions. It's really pretty straightforward...

Infarction 503 Posting Virtuoso

D. play 3 word games on internet message boards.

:lol::lol: QFT

Infarction 503 Posting Virtuoso

zearst

tazers?

Pcseetr

scepter

Infarction 503 Posting Virtuoso

Yeah, I kinda ignored the butchered post so I wasn't even looking at the syntax errors. But changing the memory pointed to by a pointer seems like a potential cause for a seg fault ;)

Infarction 503 Posting Virtuoso

Unfortunately, it won't always be accurate unless you go to great pains. This is due to there being multiple rules (and exceptions to those rules) for the English language.

Infarction 503 Posting Virtuoso

I don't know if I'm right, but I think it's because you've not defined a constructor for ExeccutionStackDemo. IIRC, the default constructor in Java is something like

Classname() { 
  super(); 
}

and since Something doesn't have a blank constructor, the default one in ExecutionStackDemo is screwing up. Why do you need the extends clause though? It's not like ESD is at all related to Something...

Infarction 503 Posting Virtuoso

Hi

Sorry about that. I tried to change few things and now I dont get any error while compiling but when I run the program, I get 'Segmentation fault'.

 vector<SampleMarketDataClient *> clients;
  SampleMarketDataClient *temp;
 while (!cin.eof())
 {
       if(cin.good())
       {
         // Read in the next line of text from the file
        cin >> lineString;
     // Set up a market data subscription.
     temp = new SampleMarketDataClient(data, loop, lineString);
     clients.push_back( temp );
 temp++;
       }
 }

Anything you can suggest? Thanks a lot.

Why do you have the line temp++? It doesn't seem like that would do what you want.

And if you wouldn't mind posting your compiler errors in code tags as well so they don't get butchered by the smilies... ;)

Infarction 503 Posting Virtuoso

yast is a package manager, isn't it? When did package managers start dealing with partitions?

I've heard of people using qparted with some successes. Always backup first, and you could try giving that a shot.

Infarction 503 Posting Virtuoso

Congratulations on copying your homework assignment. The part you copied is pretty much what you have do, except replace the arrows with = and the mod with %.

If you want more explicit help, be more explicit with your question and show that you've put some effort forth already. And procrastinating on your homework is definitely not recommended.

Infarction 503 Posting Virtuoso

post some relevant code please

Infarction 503 Posting Virtuoso

Yes, we can give you a hand. You'll find many members reluctant to throw in an arm with that deal unless you put in just as much. That said, post some code and explain what you've tried and how it's not working and we'll see how it goes...

Infarction 503 Posting Virtuoso

I don't know if my computer is just being finnicky or what, but Clinton's code didn't work right for me. Here's some code and output (trivial changes to the code):

int main()
{
  //Declare a 3D array
  int myarray[5][10][20];

  //Populate the array
  for(int i=0; i<5; i++)
    for( int j=0; j<10; j++)
      for(int k=0; k<20; k++)

        myarray[i][j][k] = k;

  //Display the array multi-dimensionally
  for(int i=0; i<5; i++)
    for( int j=0; j<10; j++)
      for(int k=0; k<20; k++)

        cout << "multi: " << myarray[i][j][k] << endl;

  //Display the array in one dimension
  for(int i=0; i<1000; i++)
    cout << "single: " << myarray[i] << endl; 
}

Output:

multi: 0
multi: 1
multi: 2
multi: 3
multi: 4
...
multi: 16
multi: 17
multi: 18
multi: 19
single: 0xbfbbf300
single: 0xbfbbf620
single: 0xbfbbf940
...
single: 0xbfc81ea0
single: 0xbfc821c0
single: 0xbfc824e0

When I used this code, I got matching outputs for single and multi though:

int main()
{
  ... // same as before

  //Display the array in one dimension
  for(int i=0; i<1000; i++)
    cout << "single: " << myarray[0][0][i] << endl;

}

it also worked with (**myarray)[i] But like Clinton said, you don't want to mess with undefined behavior...

Infarction 503 Posting Virtuoso

out of curiosity, have you tried making the putting the friend statements after the public modifier? I don't know whether or not that might change anything (I didn't need to...)

Infarction 503 Posting Virtuoso

bah, I guess I'll dust off the ol' VS2005... :p

I took the code from the first post, used a basic main to run it (making a personType and calling print()), and it worked fine.

Infarction 503 Posting Virtuoso

Erm,

cout << hello

cout << hello << "     " << hello

Negating the obvious syntax errors can you see how line three has two columns.

How weird you say. :lol:

Did you read his code? It's done that way. :rolleyes:

Here's the output I get running it:

Data type       Size
char                    1
unsigned char           1
short int               2
unsigned short int      2
int                     4
unsigned int            4
long int                4
unsigned long int       4
double                   8
double                  8
long double            12

As you can see there's a couple which don't line up quite right. What you should probably do is use setw twice per line, one for the width of the data-type column, one for the width of the size column. That way you don't have to count the length of each string and adjust the setw for size.

Another stylistic note: if I were writing this, I'd keep it to one line per cout, and end the line with a << "\n". I'm specifically thinking about line 18 and starting everything else with a '\n'. Mainly a readability issue...

[edit:] Just realized I'd misunderstood the need for 2 columns. You actually want 4 (you already have 2), and you'll need to manually change it, so it'd be something like this:

cout << setw(dataTypeColWidth) << "Int" << setw(sizeColWidth << sizeof(int) << " some spacer" << setw(dataTypeColWidth) << "double" << setw(sizeColWidth) << sizeof(double) << "\n";

and this would get a result of (using dataTypeColWidth=15, sizeColWidth=1, spacer=5 …

John A commented: Nice formatting. ;) - joeprogrammer +6
Infarction 503 Posting Virtuoso

hmm, no compiler here to test... I wuda personally done:

personType(string first, string last)
{
first = "";
last = "";
}
Again no idea if that's legal, no compiler to test it with.

Your code is completely different from his and definitely not what he's trying to do. Default paramater values allow for the parameter to be omitted when the function is called. His implementation would allow for someone to do:

personType p();
personType p("");
personType p("","");

and the three would be identical and would all go through the same constructor. Your code, on the other hand, would change the parameter values to "" inside the function body. ;)

Infarction 503 Posting Virtuoso

The following is copied from the first google result for "c++ int to string":

Q. How do I convert from int to string?

A. Converting from int to string is a little more complicated than converting a string to int. There are no standard C++ functions for this, but there is a way to do it using standard stringstreams. The class stringstream is declared in header sstream and is used like this:

std::stringstream ss;
std::string str;
ss << 31337;
ss >> str;

The variable str now contains "31337"

Infarction 503 Posting Virtuoso

It looks an awful lot like you've just posted the assignment boilerplate code. How much work have you put into this yet?

Most of your class' functions are pretty basic. The constructor initializes things, the destructor probably doesn't need to do anything for this, isfull and isempty just compare the head and tail indices and respond accordingly, size is the difference in the indices, dump prints the contents of the array and the values of the indices, and put and get have to check if the state is valid then insert a value or remove one and adjust the indices accordingly.

Infarction 503 Posting Virtuoso

>Byte is not defined as 8 bits then what is it defined as?
It's defined as whatever the implementation wants. The standard only specifies that sizeof ( char ) be 1, and at least 8 bits. That happens to be the most common definition of a byte, but systems other than your PC also support C and don't have the same definition.

So if you had an architecture that was word addressed rather than byte addressed, it wouldn't be surprising for sizeof(char) to be 1, yet that it would be 32 bits? Or is it determined by the actual implementation of your C library?

Infarction 503 Posting Virtuoso

Unsigned char is 1 byte long..
it's range is from -128 to 127

Just noticed... an unsigned char has values 0 to 255, and a signed char is -128 to 127.

That said, I seem to recall in some discussions that a char is strictly defined as a single byte (8 bits) by the standard but I'm not sure where to double check that...

Infarction 503 Posting Virtuoso

Read up on how Two's Complement works and hopefully you'll see. It comes down to 0 being counted as a positive number, and 1-127+0 is a total of 128 numbers; there's an equal number of negatives, but since it doesn't include 0, you get 1-128.

Infarction 503 Posting Virtuoso

The reason that it's -128 and 127 breaks down like this: You have 8 bits. One of them is for sign. That leaves 7 bits for the value, or 128 values. One side is 0 to 127. Since you already have 0, the other half is -1 to -128.

Infarction 503 Posting Virtuoso

20, but it'll probably go to someone 12 or 13...

Infarction 503 Posting Virtuoso

hm... somewhat surprising. I would have expected a profession like that to yield a comfortable standard of living. No wonder everyone wants to move out...

Infarction 503 Posting Virtuoso

Don't know how feasible it is in your situation, but a setup with transparent filtering (such as a proxy or firewall) would probably be easiest to monitor/log what she does and still limit what she can or can't do. Of course, this'll probably require a little more effort on your part than cybersitter or whatever (or so I assume... my parents never used those, and I would have found a way to turn it off anyways :p)

Infarction 503 Posting Virtuoso

Ancient Dragon's example will work for the first elemend of the 2D vector, and you'll probably have to nest it to go through all the rows of the 2D vector.

Infarction 503 Posting Virtuoso

Here the entry level salary is around 8K USD per annum. Very less I guess compared to other countries.

Am I correct in assuming that 8k is still a decent living?

Infarction 503 Posting Virtuoso

lasers

Infarction 503 Posting Virtuoso

canes

Infarction 503 Posting Virtuoso

A double pointer has two basic meanings. One is of a pointer to a pointer, where changing the value of double pointer will result in the original pointer being changed. Another is that of a two-dimentional array, such as a matrix, or a list of char* (e.g. in main when you use argv).

I've probably over-generalized, but hopefully that gets the idea across ;)

Infarction 503 Posting Virtuoso

I dont like apples tacicts with DRM either.

Unfortunately, DRM is the only way they'll get the contracts to distribute multimedia. I'm pretty sure MSFT is in the same boat and that they wouldn't have put so much DRM into Vista if it weren't for pressures from the recording industry... the CEOs of both companies have spoken out against DRM, or at least how it's being used. It's just a lack of consumer response that allows DRM to continue being spread.

Infarction 503 Posting Virtuoso

There was a reason for the disclaimer at the beginning... ;)

Infarction 503 Posting Virtuoso

"programming" or "Computer Science" will not teach you the specifics of an OS unless the CS part deals with it specifically. There's certainly a selection of textbooks on the subject, however, which are likely used in various curricula. Read through one of those if you're dying to know how an OS works. Grab a Linux kernel and peak through the source code of that to see one way to implement all those things. The Linux kernel is especially nice, being open source, since you can just replace parts of it with your own bits and pieces and see what does and doesn't work.

You will need to know a little assembly. Device drivers are often written in it (so I hear). And it's quite useful for threading libraries (even necessary for atomic transactions in a preemptive environment), or for other architecture specific instructions (such as popa and pusha on x86). Of course, the threading library could also be written in userspace and technically not part of the kernel. (That's just one example I've actually looked through.)

There's an awful lot to an OS. Some of it is very low-level, some of it is highly conceptual, some is a mix, some is none of the above. Get a good reference or three and see how you do. Good luck ;)

Infarction 503 Posting Virtuoso

I do not own an iPod either. Instead I have a Toshiba something-or-other featuring a 60GB hard drive, 15.4" screen for movies, and no DRM restrictions. It's silver. :p

[edit:] rofl at the results so far... 4 people with "what iPod?"

Infarction 503 Posting Virtuoso

finger

Infarction 503 Posting Virtuoso

Dont have a TV... don't really need one either... :p

Infarction 503 Posting Virtuoso

40-60K is only starting salary. professionals with experience can often get a lot more than that. On the west coast (USA) you could easily get double that amount -- of course you will need it because it will cost tripple to live there :)

Yes, here on the west coast (at least, between Seattle and Redmond), 75k-80k is about average for a student coming out of college with a Bachelor's. ;)

As to the difference between programming and SE, programming is the actual task of writing code. SE encompasses a whole process of writing, maintaining, planning, designing, etc... for a software. Typically you can get a 2-year programming degree whereas SE is often a 4-year program (2-year programs might exists, but would be relatively low level). There is also a difference between SE and CS, as CS tends to orient on the actual performance of various algorithms given various environments or inputs and a lot less on the process of developing a software.

John A commented: Agreed. - joeprogrammer +6
Infarction 503 Posting Virtuoso

chant

Infarction 503 Posting Virtuoso

punt

Infarction 503 Posting Virtuoso

There's two bugs I see here. One's my fault, the other isn't ;)

The first is that the array values are set to 0, which is null memory. They need to be given different values so that they point to memory you can write to. There's two ways to do this:
- Initialize them all at the beginning:

char* string[10];
for(int i = 0; i < 10; ++i)
  string[i] = new char[500];
// ... rest of the program
for(int i = 0; i < 10; ++i)
  delete string[i]; // free the memory
return 0; // end of main

- allocate them as you need them:

char* string[10] = {0};
// loop to read things in:
for(int i = 0; i < 10; ++i)
{
  char* temp = new char[500];
  cin.getline(temp, 500);
  string[i] = temp; // makes the pointer point to the newly allocated space
  // also need to delete at the end of the end of the program
}

The benefit of the second is that if the user only inputs 3 strings, you only allocate memory 3 times.

The second bug is that you have <= in the for loop conditions, when it should just be <. Easy fix ;)

Infarction 503 Posting Virtuoso

The easiest way would probably be to take the input as a string and compare each character to '1' and '0'. This will also help you tell if the user entered something like "101234" or "16oz."

Infarction 503 Posting Virtuoso

If you want to get a better idea of configuring a Linux distribution (or as some may claim "how they work"), I'd recommend one of the less "noob-friendly" (or more "advanced") distros like Gentoo, Slackware, Arch, or Linux From Scratch. My personal favorite distro is Gentoo, though it is admittedly a task to set it up (I've not tried any of the others I just listed yet ;)).

Jaseva commented: Thanks for the info :) ~Jaseva +1
jbennet commented: lfs would not be suitable itll put him off linux for life -1
Infarction 503 Posting Virtuoso

Here's some pseudocode for two ways I might do it:

int main()
{
  char* stringDB[10] = {0};

  // method 1: add in order
  while(/* condition to keep inputting */)
  {
    read in a line
    find where the line goes
    put the line in the correct spot, adjusting others as necessary
  }

  // method 2
  for(int i = 0; i < 10 && /* condition */; ++i)
  {
    input string and add it as stringDB[i];
  }
  sort stringDB;

  // then output
  for(int i = 0; i < 10; ++i)
    std::cout << stringDB[i] << "\n";
}

When you sort the char* array, you can use strcmp (from <cstring>) to compare them.

Infarction 503 Posting Virtuoso

snout

Infarction 503 Posting Virtuoso

haha, ~s.o.s~ we're in the same boat. So much for being original...

Infarction 503 Posting Virtuoso

scoot

Infarction 503 Posting Virtuoso

I guess I could set up VMWare, but I was mainly trying to see how VIsta compares on its own, and I've heard that running things in a VM does make a noticeable speed difference.