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

Two (2) videos for your consideration; Coheed and Cambria!

http://www.youtube.com/watch?v=BsgOl-vedtA

http://www.youtube.com/watch?v=q2dYicFvLac

Thanks a lot man, these links are so cool...

Please do me a favour and keep me posted of such things.. ( i am not much in touch with metal nowadays)

Thanks again.

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

i mastered vb for concepts then c++ console apps, then i leart basic win32/mfc then i got a book on directx game making which came with tutorials, modelling software and an IDE

I agree with you completely.
Not many people fully understand what is meant by "Rome was not built in a day".

Before you run, you must learn to crawl.

I started off with basic C programs, OpenGL, DirectX, then third party game engines ( Irrlicht ), modelling tools like Milkshape 3d and animation tools like character FX.

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

Hmm.. if the number of entries in the file can range from 8 to 99.. why bother creating a static array which will unnecessarily take up space. Why not do it in a more effective way:

char buffer[512] = { '\0' } ;

// keep on reading from file till EOF
while( fgets( buffer, 512, file_pointer ) )
{
   sscanf( buffer, ......
   // and so on..
}

This will make your code flexible, be it 99 or 999 lines.

As far as the display part is concerned, when you accept the input from user which is the song number, store it is a variable like "tmp_num".
Run a for loop through the entries of your array and if the "tmp_num" matches with any select[index] then print out an * in front of only "names[index]" .

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

I wont be left behind: :D

Very touchy one:

Pick up the bones by Alice Cooper

Collecting pieces of my family
In an old pillow case
This one has a skull

But it don't have a face
These look like the arms of father so strong
And the ring on this finger

Means my Grandma is gone
Here's some legs in a cloud
Where my sister once played

Here's some mud made of blood
And these teeth are decayed
The ear of my brother

The hand of a friend
And I just can't
Put them back together again

Pick up the bones
And set them on fire
Follow the smoke going higher and higher
Pick up the bones
And wish them goodnight
Pray them a prayer and turn out the light

There are stains on the floor
Where kitchen once stood
There are ribs on the fire place
Mixed with the wood

There are forces in the air
Ghosts in the wind
Some bullets in the back
And some scars on the skin

There were demons with guns
Who marched through this place
Killing everything that breathed
They're an inhuman race

There are holes in the walls
Bloody hair on the bricks
And the smell of this hell
Is making me sick

Pick up the bones
And set them …

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

These two loops have nothing in common. Change the while loop to look like the for loop.

Dont you think you are forgetting something in your code -- something like incrementign the index value so as to provide the terminating condition for the loop.

while(status !=EOF)
     {    
          time[index] = number;
          fgets(list, 99, inp);  
          strncpy(names[index], list, 28);
          names[index][29] = '\0';          
          status = fscanf(inp, "%d", &number);  
          ++ index ;
     }
}

Also If you sure that there are only 8 records then why not:

index = 1 ;

while( index < 9 )
{
  // your stuff goes here
  ++ index ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you have got the working program, please post it here so that the others who refer this thread can see the solution and benefit from it.

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

Hey, just keep the good old "dark lyrics" coming will ya... :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include <iostream>
#include <fstream>

using namespace std;

class Matrix {
    public:
        Matrix(int,int);
    private:
        int rows, cols;
        int **EL;
};//Class Matrix

Matrix::Matrix(int r,int c)
{
    rows = r;
    cols = c;
     **EL = EL[rows][cols]; // you cant do this in C / C++
   
// when you create pointer variables you cant use them until you have
// allocated them memory. A pointer points to just junk unless done so.
// IN this part you need to paste the code for two dimensional matrices
// which I just showed back to you a few posts back.

// Again I ask you the same question, "why not use vectors" ?
// It makes the task a lot easier by taking away the gory mem
// management issues away from you, and also provides you with
// bound checking.

// For information on vectors visit here

// Also if you want a reference while building your matrix classes 
// you can take the help of this source code

 }

Also if you want two dimensional matrices in C++ vectors look here

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

[IMG]http://www.daniweb.com/techtalkforums/Upward%20over%20the%20mountain[/IMG]:sad::sad::sad:

If you feel that is sad... see this:

Poetic Tragedy by " The Used "

The cup is not half empty as pessimists say
as far as he sees nothing's left in the cup
A whole cup full of nothing for him to indulge
since the voice of ambition has long since been shut up

A singer, a writer,
he's not dreaming now of going no where
he gave heed to nothing
and all that he was is just a tragedy

So he voyages in circles succeeds getting nowhere
and submits to the substance that first got him there, there, there, there

violent frustration
he cries out to God or just no one
is there a point to this madness
and all that he was is just a tragedy

He feels alone
His heart in his hand
He's alone
He feels like
I feel

Then on that last day he breaks
and he stood tall
then he yelled, then he yelled
(Why world? WHY WORLD?? Hate you! HATE YOU!!! BYE WORLD!!!!!!)

violent frustration
he cries out to God or just no one
is there a point to this madness
and all that he was is just a tragedy

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

You have made quite a few mistakes there. It would be good if you went back to study the material provided to you before you dive head first into coding.

But still I am pointing out the mistakes to you.

#include <fstream> // you forgot to include this i think
using namespace std ;

class Matrix {
    private:
         Matrix(int,int); 

// constructor cant be private since it gets 
// called whenever a new object is created in main
// private data members and functions can be accessed only
// in the class in which they are present

         int rows, cols;
        int EL[rows][cols]; 

// you cant have variable length arrays in C / C+
// why bother with this, either make it a double pointer to int
// or better yet use vectors of C++.
 };

Matrix::Matrix(int r,int c)
{
    rows = r;
    cols = c;
}

int main()
{
    int a=0,b=0;

    ifstream inflie("input.dat"); // spelling mistake

     infile>>a>>b ; // missing semi colon

     Matrix A(a,b);    
    return 0;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

By the way, what has shamanism got to do with opening up dead threads. Does a shaman bring the dead back to life?

In Diablo II they sure do :mrgreen:

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

This is where your experiece and expertise in the field of Object Oriented practices comes into play and you would be faced with such situations during project development.

Normally one liner functions are kept inline since inline functions are pasted at the place of their call and not called like normal functions.

Hence accessor functions like getValue( ) , setValue( ) etc. are normally made inline.

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

Why is that?

Ah.. my bad, sorry I was thinking of somthing else.:confused:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
template <typename C, int cnt>
struct Definer
{
    static const C d = cnt - 1;
    Definer<C, cnt-1> f;

    C const& lookup(int index)
    {
    if (index == (cnt - 1))
        return d;
    return f.lookup(index);
    }
};

template <typename C>
struct Definer <C, 0>
{
    static const C d = 0;

    C const& lookup(int index)
    {
    throw 18;
    }
};

i

Dont you think the "typename" should be replaced with "class" ?

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

I love Manowar

"Brothers of Metal" have you heard this song :mrgreen:

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

This is software development and not virus developmen forum.

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

How about something like:

int main(void)
{
    char buffer[] = "1941 How Green Was My Valley; John Ford." ;
    int year = 0 ;
    char title[BUFSIZ] = { '\0' } ;
    char director[BUFSIZ] = { '\0' } ;
    if ( sscanf( buffer, "%d %[^;]; %[^.]", &year, &title, &director ) == 3 )
        printf( "Year = %d, title = %s, diretro = %s", year, title, director ) ;
    getchar( ) ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The array subscript operator takes the offset, size, and index and computes a new offset equal to offset + (size * index).

In my previous implementation of the overloaded [ ] operator, make use of the logic you have stated and it should work out to be fine. After all the implementation of the [ ] is entirely in your hands so you can calculate a new offset and return the value corresponding to the new offset.

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

If you are allowed to use inbuilt functions, why are you writing your own code for makeing the characters uppercase. Just use:

for( i = 0; i < MAX_LETTERS; ++i )
{
    letters[i] = toupper( letters[i] ) ;
}

This will make the entire contents of the array uppercase.

Loop through array with something like to count each character:

for( i = 0; i < num_used; ++i )
{
    count[ letters[i] ] ++ ;
}

Try this thing and repost.

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

I wanted to be able to declare

C array[4];

to make it clear that array was an array of four. But I could declare a second type, maybe called CArray (or FooArray -- ArrayOfC, something). Just something to let the reader know that this is an array of elements.

I dont get what you actually are trying to say. Mind if you give a small eg. coz you originally post stated:

rather I'd like it to call my own [] operator.

Also explain what do you mean by "my own [ ] operator"

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

YES it is possible.

Its pretty simple once you understand the basis:

template <class T> class Array {
private:
  T* storage;
  int size;
public:
  Array(int arg = 10) {
    storage = new T[arg];
    size = arg;
  }
 
  ~Array() {
    delete[] storage;
    storage = 0;
  }

T& operator[](const int location) throw (const char *);
};

template <class T> T& MyArray<T>::operator[](const int location)
  throw (const char *) 
{
    if (location < 0 || location >= size) 
        throw "Invalid array access";
    else 
        return storage[location];
}

int main() {
  try {
     Array<int> x(13);
     x[0] = 4;
     x[1] = 5;
     cout << x[0] << endl;
     cout << x[1] << endl;
     x[13] = 84;
  }
  catch (const char* e) {
    cout << e << endl;
  }
}

The following is the output of the above example:
4
5
Invalid array access

Hope it helped, bye.

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

neither is the new operator and classes.

Naa you are missing the whole point. POD rule is voilated is any of those things are used which cant be represented or have equivalent in C.

Equivalent of new in C => malloc and calloc
Equivalent of classes in C => structs

I hope you get the point.

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

When the class "My" inherited from class "Base" it no longer remained a POD hence the different results. YOu can be rest assured that the ( ) notation always initializes the POD data.

Since inheritance is not supported in C, the moment My inherited from Base, it voilated the rule, since there is no equivalent of inheritance in C i.e. no conversion possible for the class My to make it C compatible.

Conclusion:

You can trust on ( ) to initialize "ONLY" POD and that too if the pointer is of type POD.

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

Firefox 1.5.0.7

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

Please be a bit more specific, since this is nor pure C++ but SDL mixed along with it, and also due to the lengthy code it becomes difficult for us to pin point the problem.

What exactly happens, does the ball go through the bricks, what do you mean by the collision occurs only with the top brick , which part of your code is concerned with collision ( mark it with red or blue ) ?

Be a bit more specific.

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

For Vitsa screenshots visit this link:
http://www.only4gurus.com/v3/longhorn.asp

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

Hmm.. so it figures that the VS 2005 has the same output as the GCC compiler. Strange...

Better stick to the round bracket notation since it always seems to initialize the POD.

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

Hmm maybe it is because you must be using MS Visual studio. BTW I am using MingW GCC latest compiler.

I am attaching the executable, you can see for yourself that the thing works in my case:

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

Okay to put it in a simple way, the round bracket syntax is used when you want to initialise the primitive data type varibles in your class with their defalut value while you ignore the brackets you just get an uninitialized object.

class My
{ 
   public:
      int a ;
} ;

int main( )
{
    My* first = new My ;
    My* second = new My() ;
   
    // this will print out junk i.e. uninitialized value
    cout << "value of var init without round brackets : " << first->a ;
   
    // this will print out 0 i.e. initialized value
    cout << "value of var init with round brackets : " << second->a ;
}

Similarly the round brackets beome mandatory if you want to pass values to the class constructor -- something you cant do by ignoring the round brackets.

If you want to see a full blown explanation you can look here

Hope it helped, bye.

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

Looks like someone has got balls of titanium. :D

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

using balls as brakes.

Wonder how long will they last if done so.....:twisted:

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

Knock knock... do I see somthing missing...

#include <cstdlib> 
#include <iostream>
#include "Look.h"
using namespace std;

int currPos = 0;
int checkFlag = 0;
static int shipPos1 = 0; // default start position (pos 0)                                
int shipPos2 = 228;

// 3.80 minutes (228 seconds) 

Look::Look() {
}

Look::~Look() {
}

void Look::printShipPos() 
{ 
      if (checkFlag > 1) {
        shipPos = shipPos2 + 228; 
        cout << shipPos << endl;
                           }
        {    
// ouch
if (shipPos = 228) {
   std::cout << "French Polynesia [Out of Transmission Range]"<< endl; 
}
else if ((shipPos > 228) && (shipPos < 456)){
  std::cout << "Maui, Hawaii [Out of Transmission Range]"<< endl; 
}
else if ((shipPos >= 456) && (shipPos < 684)){
   std::cout << "Pacific Ocean (open waters) [Out of Transmission Range] 4320 miles from Tampa, Florida"<< endl; 
}

.
.
.

//---------------------counter for fly-over access
checkFlag++; 
cout <<checkFlag<< endl;

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

That site doesn't seem to work. I keep getting asked to authenticate myself.

No such thing here, it works fine for me.

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

P7K

Damn... talk about ripping off someone else's title ;)

BTW congratulations, Mr. DMR

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

Thanks for the quick response. this might be a dumb follow up, but what does the size(int) do at the end of that new array?

and one more thing... i dont think i was clear when i said this in the original post. It has to be a multi dimensional array so would i initialize it like this?

array = new int[nRows][nCols];

No you cant do this. Also Mr. Dragons code

int nRows, nCols;
int* array;
file >> nRows >> nCols;
array = new int[nRows * nCols * sizeof(int))];

assumes that the array locations of a two dimensional array are contiguous which may not necessarily be true if the optimizing compiler decides to align to the double word boundaries ( microprocessor related ).

Try somthing like:

int main()
{
    int** a = new int*[3] ;

    for( int i = 0; i < 3; ++i )
    {
        a[i] = new int[3] ;
    }

    for( int i = 0; i < 3; ++i )
    {
        for( int j = 0; j < 3; ++j )
        {
            a[i][j] = i + j + i * j ;
        }
    }

    for( int i = 0; i < 3; ++i )
    {
        for( int j = 0; j < 3; ++j )
        {
            cout << a[i][j] ;
        }
        putchar( '\n' ) ;
    }

    return 0;

}

Mr. Dragon, I dont think there is need in C++ to supply the size of the data type whose array you want to create since new …

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

Tsk tsk... nowadays everyone wants to be a shaman, resurrecting dead threads......

Thread closed.

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

The loss of indentation makes the code impossible to read and find the problem areas. It would be really better if you indented the code and resposted.

Some points:

1. WHy is the logic for counting the characters present in the function make uppercase? Why not create a seperate function for it?
2. Are you not allowed to use inbuilt functions ?

Answer the above questions and indent your code so that it becoems easy for me to help you out.

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

Deleting dynamically allocated array is done in C++ using the special delete syntax : delete[] array_persons ; where you had allocated the array with something like: int* array_persons = new int[10] ; An eg.

int main()
{
    int* a = new int[10] ;
    for( int i = 0; i < 10; ++i )
    {
        a[i] = i ;
    }
    delete[] a ;
    return 0 ;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It is nothing as such related to programming in C as such, it is something related to the forum posting rules.

Read this page and you will understand:
http://www.daniweb.com/techtalkforums/announcement8-3.html

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

Please dont be vague. It doesnt work, doesnt convey us anything. State what kind of output were you expceting and what have you got.

BTW did you take a look at the prev post of Mr. Dragon, he pointed out some problem in your code, did you get it corrected ?

Also post your updated code.

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

Bingo!!

And Miss please dont forget to use the code tags next time while posting your code.

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

Okay now to achieve the hollow effect we observe a few things:

1. The box will have complete lines of * only for the first and the last rows.

* * * * * * <=  First row complete line
*            *
*            *
*            *
*            *
* * * * * * <=  Last row complete line

2. So in your program, both the while loops will virtually remain the same except for the fact that the logic within the second while loop should be updated to take care of teh condition I laid in front of you.

Something like:

while( i <= limit )
{
    while( j <= limit )
    {
         if( first and last row )
         {
              // handle it in a different way
         }
          else
         {
             // we need only the first and last *
             // handle differently for the rem. rows
         }
     }
}

Try it out yourself and it will definately work.

PS: Please enclose the code you post in [code] // your entire code [/code] tags .

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

An introduction to what, or whom for that matter?

He wants to know about you :mrgreen:

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

Firefox for me. (with all the extensions available on the net, I can make a godly browser out of it)

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

Hmm.. if you want to code this thign from scratch, you need to use some socket library. (like winsock for windows)

Maybe looking at this thread would help a bit:
http://www.daniweb.com/techtalkforums/thread50205.html

Hope it helped, bye.

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

Wait... do I see The Dude holding a knife in his hand, bloodshot eyes and "I am gonna kill Iamthwee" written all over his face :D

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

I wont write teh code but give you a general algo:

1. Move through the array counter.
2. If at an index i you encounter a value > 0 display the equivalent character of i.
3. After the above condition is satisfied, start a for loop which will print out the number of stars which equals the vaule of the counter for that particular i in front of the character.

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

My favourite genre:

Fiction
Tech Related
Spiritual

For fiction I prefer P.G. Wodehouse (comedy), Agatha Christie (murder mystery) and Perry Mason ( courtroom murder mystery)

For tech related, it can be any gaming magazine, normal PC magazines, articles on the internet and what not !!

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

No...I think you dont get the logic.

while( ! ischar( str[i] ) ) { ++i ; }
// increment the counter here since "i" points to an alphabet
counter[str[i]] ++ ;

Do the same for the other loop.

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

alpha[128] += 1 ; I dont know what you are trying to do here, but if the array if of 128 elements you can only do till my_array[127] since the arrays are zero indexed i.e. the indexing of arrays starts at 0 ( due to internal represenetation being of pointer type).

Also as you already must be knowing you can use a variable to index into the array like: my_array[i] = some_value ; Use the same trick , but in your case instead of 'i' you use the integer value of the character encountered.

For eg. my_array['a'] += 1 ; will increment the value of my_array[97] since 'a' is equivalent to 97 (based on the ascii table)

Use this trick to increase the counter as soon as you encounter an alphabet.

PS: I am attaching the ASCII table for your referncce.