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

On this point I would argue if you have lots of knowledge, but no special knowledge you are in danger of becoming a Jack of all trades instead of a master craftsman. (this is my biggest problem I'm too interested in all of it to stick to a genre)

Come on my good friend, u mean to tell that by using a particular compiler or tool and using it perfectly crosses the thin line between Jack of All Trades and A Craftsman then i completely disagree.

Take for eg. the two UML tools Sparx Enterprise and Rational Rose. I completely agree that once you know what is where and the nifty tricks of the software then the productivity is definately boosted but it is no replacement of the knowledge of UML which is driving you to use the software. And suppose u have to switch to some other UML modeling tool then its the knowledge and understandign of UML which would save you and not the knowledge of a particular tool.

But this is just what i think...
Opinions may vary.

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

Err...

@Mr.Ancient Dragon

I was advised here that the call system ("PAUSE"); calls the operating system procedure which is not very advisable since ther is a switch is the context.

Are there any exceptions to this rule since u have used that stmt in ur code ? Just curious ...

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

But stilll i agree with WaltP.

IF any construct or any stmt for eg. fflush (stdin) suppose would be defined under one compiler it would make really less sense to adopt it if it results in undefined behaviour on other compilers. (though it really is undefined under all implementations)

In the end, undefined behaviour of any kind should be very much avoided.

And btw carrying on with ur eg., if the artist knows what wood he is supposed to use and the knowledge of how that wood can be made into a beautiful engraving or a piece of art then it really doesnt matter in which part of the world he is, he just needs to know wat tools are at his disposal and he is all set to make the next masterpiece.

In the end its the knowledge which is more important than the tool, so if asked to make a choice i would very much choose Knowledge over proficiency of a particular Tool.

Hope u take all this is good faith.
Bye.

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

Can we say that for C also? i.e C is semantic superset of C++. Everything you can do in C++ you can also do in C.

Maybe u r confusing between superset and subset.

a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
b = {1, 2, 3}

Here b is the subset of a .
Here a is the superset of b.

In the same way C++, the one with more functionality and inheriting almost all the syntax from C and adding on its own is a superset of C.

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

Maybe something along these lines should do the job in a simple way.

char* changeString (char* sourceStr)
{
    char* tmpStr = sourceStr;
    int strLength = strlen (tmpStr) - 1;
    for (int i =0; i < strLength; ++i) {
        if ( *(tmpStr + i) == ' ')
            *(tmpStr + i) = '_';
    }
    return tmpStr;
}

int main () {
    char name[BUFSIZ];
    fputs ("\nEnter the string: ");
    fgets (name, BUFSIZ, stdin);
    fputs ("\nThe new string is: ", stdout);
    fputs (changeString(name), stdout);
    getchar ();
    return 0;
}

Hope it helped,
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
int i=0, j=1;
cout<<(j++)&&(i++);   //output=1

Is taken as (cout << (j++) ) && i++ .
Here the function cout returns the characters successfully printed which is of type int basciallly a number which when AND with a number gives another number. In the end the above stmt will look to the compiler like someNumber; which is successfullly parsed by the compiler without generating any error and the required output is generated as a side effect of the cout stmt.


Hope this explanation helped u.
Bye.

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

Thanks a lot for the optimizations both of u.
Completely forgot to take that into consideration.

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

Mr. Wolf any suggestions to my working code, can it be made better.

int isPrime (int number)
{
    if (number == 2)
        return 1;

    if (number % 2 == 0)
        return 0;

    for (int i = 3; i < number / 2; i += 2)
    {
        if ((number % i) == 0)
            return 0;
    }
    return 1;
}

Thanks in advance.

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

The problem with ur code is that u are ussign int *pbits without allocating memory to it using new () so a crash is for sure.

Try allocating some memory to it like

pBits = new int [1];        // allocates memory for one int element

Hope it helped,
bye.

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

Why do you care about the speed anyways?

If the developers didnt care for speed then u wouldn't be conviniently using your favourite OS u are usign right now without atlest swearing atleast 100 times a day regarding the slow loading times.

Dont forget that this is a C/ C++ forum and speed is one of the major merits of this language and bcoz of which it is used to make real time softwares.

Though optimization should be last on ur list but it still is nevertheless an issue to be handled.

EDIT:
@hollystyles: btw 1 is a composite and 2 is a prime number

Here is a convinient and easy to understand way of fiding primes:

int isPrime (int number)
{
    if (number == 2)
        return 1;

    if (number % 2 == 0)
        return 0;

    for (int i = 3; i < number / 2; i += 2)
    {
        if ((number % i) == 0)
            return 0;
    }
    return 1;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include <iostream.h>
void main ()
{
int s;
 
   if ((s>=90) && (s <=100))
   {
     return 4;
   }
   else if((s>=80) && (s<=89))
   {
     return 3;
   }
   else if ((s>=70) && (s<=79))
   {
  return 2;
   }
   else if ((s>=60) && (s<=69))
   {
  return 1;
   }
   
}

First of all, read teh forum guidelines and rules before posting and enclose the code in code tags.

Looks like you must first get ur basics cleared by reading some good tutorials on the web or just google it.

Here are some things u need to change about ur code

>>> #include <iostream.h> Dont use C type includes, make use of C++ styles includes to make avail to urself the power of C++ std library.

>>> void main (void) main returns int not void as a signal to OS about its execution status.
0 on success and anything else on failure.

>>>
YOu have declared a variable int s; but either defined it nor have u taken any input from the user hence it will initially contain garbage value. Somethign like

int s = 89; // defining s

OR

int s;
cout << "Enter the value of s: ";
cin >> s;                                  // getting input from user

>>>

return 1; // this should be return 0;

Returning 1 means the program has encountered some error. A properly executed program returns 0 value.

Hope it helped,
bye.

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

Man dont u ever give up, i think this is the second time u are replying to a dead post. Please dont make this forum a graveyard and follow the forum guidelines before posting.

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

Maybe this can give a rough idea on how a function is organized

float calculateArea (float length, float breadth)
{
    return (length * breadth);
}

float calculatePerimeter (float length, float breadth)
{
   return (2 * length + 2 * breadth);
}

and this can be called in main using

cout << "THe area of reactangle is " << calcuateArea (length, width);
cout << "THe perimeter of reactangle is " << calcuatePerimeter (length, width);

Hope it helped,
Bye.

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

Hmm i can try it for u but it takes time so dont expect the ans to come in the minute u see this post. I will see what can be done. Maybe tomo i would be in a better frame of mind to think about your problem.

Bye.

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

Better post ur effort along the guidelines which i have provided and then we will see where is ur code lacking and what needs to be changed. But first and foremost ur effort at solving the prob is a must.

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

Which error are u talking about or is it a crash? Its better to post the errors you get from ur code rather than asking us to find it for u.


Still some points which can be clarified about the code are:

> Also it is not advisable to put the entire implementation in the header file since in the end teh compiler ends up pasting the whole code of the header file at the place it is included. It would be better if u have three files like "stack.h" , "stack.cpp" and "test.cpp" where stack.cpp would contain the implementaion present in the header file.

> Since a stack can dynamically increase in size to the max of the size of virtual memory (heap size) what is the point in keeping a function bool isFull ( ) . What is the code u will implement there ?

> Also I think that by keepig the stmt delete temp; in your push (int value); you are actually deleting the newly formed node thereby deleting all the nodes that are created and removing or claiming back the memory allocated to it.

Hope it helped,
bye.

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

Maybe the documentation of the external library you are currently using will have some pointers on how u can go about doing this.

Also without the complete code it becomes difficult to think of a solution.

HOpe it helped,
bye.

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

One way to do it is to create a struct called result like this

typedef struct result_
{
   int frequency;
   char* line;
} result;

And dynamically create an array of this struct to add the results found as well as the frequency of occurance. While getting every single line from the file comparisions have to be made with the temp array of struct and if a match is found to increment the frequency.

Mind u this method is very computationally intensive so think of some optimizations that can be made.

Hope it helped,
bye.

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

YOur function is like

char* subArr(char array[65535], int length)
{
    int i, j = 0;
    ****    char temp[65535 - length + 1];    ****
    for (i = length - 1; i < 65535 - length - 1; i++) {
        temp[j] = array[i];
        j++;
    }
    return temp;
}

To be in control of the array returned by the function you can try allocating the array or placing it on heap memory using the call to "malloc" somewat like this

char* subArr(char array[65535], int length)
{
    int i, j = 0;
    char*  temp = (char*) malloc (65535 - length + 1);
    for (i = length - 1; i < 65535 - length - 1; i++) 
    {
        temp[j] = array[i];
        j++;
    }
    return temp;
}

So here u are in command of the array returned. But do take care to free the allocated memory when u are done with the returned array. free (temp) Hope it helped,
Bye.

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

thx for ur help but i am still in confusion .. i am using ofstream functon of ifstream header file ... its syntax is

ofstream buffer ("filename" , file mode)

but since file is placed in a folder in bin so where can i define pth for file as ofstream function can locate files only in BIN folder .

If u want the buffer ("fileName", "fileMode"); to work at a custom defined location, for eg. BIN in your case then you can try somthing like this: buffer ("c:/c compiler/BIN / file.txt", "w"); Hope it helped,
bye.

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

For encoders and decoders of the popular image standards
http://www.colosseumbuilders.com/sourcecode.htm

And the whole opensource image processing library suite in C++ is available at http://cimg.sourceforge.net/

Hope it helped.
Bye.

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

If by musical note u mean a beep then it can be done using

for (int i = 0; i < 20; ++i)
        prinf ("\7");

will sound the beep 20 times.

If u mean musical notes like piano and the likes then maybe an external sound library would be more like it ( OpenAL, FMOD ??).

Hope it helped,
Bye.

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

if you have read or use Learn C++ in 24hours is it a good book to learn form or is it a pile of paper to burn?...

or object oriented Programming in c++ is that a good (graphics) bbok?

You should be really ashamed of yourself saying such a stmt.

There is no such thing as good or bad book, its only the target audience that changes. Learn C++ in 24 hrs is a good book for all those who want to know the basics of C++ so that they can move on to more advanced concepts.

And do u weigh whether a book is good or bad dependign on the graphics ? Come on man u got to be joking !!!

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

Please post the code using tags.

char* number = new char[20];
cin>>number;
c.postfix(number); // use fuction postfix to convert

and this is my postfix fuction

void Calculator : Postfix(char* item)  
{
 // give variables meaningful names
// instead of "item" , "expression" would have been a better choice
// the same applies to i1
  int i1; 
  for(int i=0;i<20;i++)
  {
    [B]if(item[i]='+')    // this should be if (item[i] == '+')[/B]
   {
      i1 = atoi(item[i-1]);  // if using C++ y use old C functions
      // also i think atoi works with only null terminated strings

      item[i]=item[i-2]+item[i-1];
      top=top-2;
      i=i-2;
      stack[top] = item[i];
    }
    else 
   {
      stack[top] = item[i];
      top++;
    }
 }
}

Hope it helped,
Bye.

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

> So better keep in mind that if the file is not present a new one with the same name will be created.
Not if you're opening it for reading it won't.

Damn how could i have ignored it, yes thats true.
Thanks for the correction.

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

POst ur current effort and we will see what can be done.

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

Here is an extract from K & R C programming Tutorials

A file is opened by a call to the library function fopen(): this is available automatically when the library file <stdio.h> is included. There are two stages to opening a file: firstly a file portal must be found so that a program can access information from a file at all. Secondly the file must be physically located on a disk or as a device or whatever. The fopen() function performs both of these services and, if, in fact, the file it attempts to open does not exist, that file is created anew. The syntax of the fopen() function is:
FILE *returnpointer;
returnpointer = fopen("filename","mode");

So better keep in mind that if the file is not present a new one with the same name will be created.

Bye.

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

It would be really good if u could post the data file so that we can run the prog and see wat actually is the problem rather than assuming somethings.

Also if u are using C++ y not use string instead of character arrays.

Bye.

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

I got 10 lines. ;)

#include <windows.h>
#include <iostream>
using namespace std;
int main(){
POINT c;
GetCursorPos(&c);
int x=c.x;
int y=c.y;
cout<<x<<", "<<y;
system("PAUSE");}

Dont say things without reading the entire post submitted by a very experienced and senior member.

What he wanted to said that if u intended on drawing a window or creating a window u need atleast 60 - 70 lines of code which is well formatted.

What u have written above is not a GUI or window application but a console application.

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

Ok so does he mean the variable argument passing, phew wat a way to frame the question.

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

Yes sad but true but i pointed out this thing to him saying that it was his typing mistake and not the textbook's. So he may hopefully not blame the author in the future.

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

Just out of curiosity, who wrote this code?

int main () 
{ 
    char board[NUM_ROWS][NUM_COLS];   // Message board 
 
    // Initialize the message board to all periods. 
    fillRectangle(board,0,0,NUM_COLS,NUM_ROWS,'.');

He says its given in the manual, or maybe written by his professor.
Why, do u like it that much ;)]

Maybe u thinkin y to pass so many parameters if u eventually want to initialise the whole board.

Just write, void initialiseBoard (char reqChar);

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

Ok apology accepted, but wat do u now expect, wat is the prob with the code now ?

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

oh great, the code i'm not writing is fucked. i'm glad this class is over wednesday.

What the hell is this supposed to mean !!!

Explicit content is not allowed on the site even if it reflects ur feelings.
And with this kind of replies i dont think you would get any help in the future so it would be better if u stop saying such things and apologise.

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

It would be really good if u could post the actual requirement ur code is supposed to satisfy and ur actual effort rather than making us do the guesswork. That way u can get more help.

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

The only problem with ur code is that u are passing parameters to the function fillRectangle ( ... ) in the wrong order ( yes u heard it right WRONG ORDER).

The first call to fillRectangle ( ... ) should not be fillRectangle (board, 0, 0, [B]NUM_COLS, NUM_ROWS[/B], '.'); but it should be

fillRectangle (board, 0, 0, [B]NUM_ROWS, NUM_COLS[/B], '.'); The rest of the code is fine.
Hope u have understood the problem.

An alternative method which can save u from such bugs is to write two functions like void initialiseBoard (const char reqChar) to initialise with the req char and then call the method fillRectangle ( ... ) .

Hope it helped,
Bye.

~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

So wat exactly works on ur PC, the GLUT code or the OpenGL code.

Try this link which explains how to setup OpenGL on DEV C++
www.zeuscmd.com/tutorials/opengl/02-SettingUpYourEnvironment.php

Hope it helps,
Bye.

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

In your prev post u said it worked, then wat was it that worked ?

Also it would be better if you read the instructions present in the last link i posted to you about configuiring the Dev C++ for OpenGL.

Also it would be better if you elaborate your problem a bit more by giving the code and the exaxt error messages.

Bye.

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

Just getting the source code copied from any website is not much of an achievement, it would be better if you do a reality check and start learning C++ from ground up , from beginner to advanced and you will automatically figure out the answers to your questions.

Sorry if i have been rude but its best to have strong basics than just jumping in the fray not knowing wat the hell is going on.

Bye.

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

Glad i could help.
If you are starting C you might want to take a look at some of the C resources at http://www.daniweb.com/techtalkforums/thread50370.html

Hope it helped, bye.

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

Goto the sticky http://www.daniweb.com/techtalkforums/thread50370.html where i have posted links for two free ebooks available on the net for OpengGL as well as a graphics programming book for developers if u are intrested in that.

Hope it helped,
Bye.

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

Are u sure u have done the following things :

2.Download glut.
Get glut-3.7.2-dlls.zip (104 Kbytes) or the latest glut version from http://www.xmission.com/~nate/glut.html
3. Unzip glut**dlls.zip.
4. There are two sets of files, one for Microsoft's OpenGL (files with 32 in filenames) and one for SGI's OpenGL (no 32).
5. Copy glut*.dll to
Win 98: windows\system
NT or Win 2K: winnt\system32
6. Copy glut*.lib to Program Files\ MS Visual Studio\VC98\lib\.
7. Copy glut.h to Program Files\ MS Visual Studio\VC98\include\gl.

Chck if the above steps have been performed.

If u still have problems goto this site for instructions:
http://www.lighthouse3d.com/opengl/glut/

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

char s[]="the cocaine man";
int i=0;
char ch;

ch=s[++i];
printf("%c ",ch);

You pre increment the value of " i " which now becomes 1 and u access ch = s [1] which is 'h' the second char of the array.

ch=s[i++];
printf("%c ",ch);

This time u use the post increment operator i ++ which causes the prev value of " i " to be used which is 1 and then increments it. So after this expression the value of i is now 2.

ch=i++[s];
printf("%c ",ch);

Arrays can be accesssed as arrayName [index] or index [arrayName] . For eg i can access an array as 3 [arrayName] = 'a'; which will set the fourth element of the array to character a.
Hence u use indirectly ch = 2 [s]; which is 'e'.
At this point the value of i becomes 3.

ch=++i[s];
printf("%c ",ch);

You now increment the ascii value of the character at position 3 which is a space ' '. The next character in the ASCII table after ' ' is ! hence the output.

output = h h e !


Hope it helped,
Bye.

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

Thx that worked but now i want to put a string in a class i tryed this Didnt work

I have highlighted the section which you forgot towrite or had wrongly written.

Try this

#include <iostream>
#include <string>

class Name
{
     string myname;
public:
     Name();
     ~Name();
     void print();
};

Name::Name()
{
     myname="mark";
}
Name::~Name ()
{
}
void Name::print()
{
     cout<<myname;
     
}
int main();
{
     Name firstname;
     firstname.print();
     return 0;
}

It would be really better if you started C++ using some basic c++ tutorials, get the basics straight, read some theory and then start programming.

Hope it helped,
bye.

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

You should use strcpy (char* destination, const char* source) to copy the contents of one char array to another, not the normal assignment stmt "=".

Putting this in place of ur code should do the trick strcpy (holidayCopy, holidayList[i].holiday); Hope it helped,
Bye.

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

holidayCopy is a character array and i think holidayList.holiday is a char variable of the DayData class.

You are trying to assign a character to an array which is illegal.

Maybe this is wat u are lookiing for : holidayCopy[i] = holidayList[i].holiday; Hope this helped,
Bye.

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

Just for testing purposes compile and run the code and see if it works.
If you have any errors report them back,

#include <GL/glut.h>


void renderScene(void) {
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_TRIANGLES);
		glVertex3f(-0.5,-0.5,0.0);
		glVertex3f(0.5,0.0,0.0);
		glVertex3f(0.0,0.5,0.0);
	glEnd();
	glFlush();
}

void main(int argc, char **argv) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
	glutInitWindowPosition(100,100);
	glutInitWindowSize(320,320);
	glutCreateWindow("3D Tech- GLUT Tutorial");
	glutDisplayFunc(renderScene);
	glutMainLoop();
}

Bye.

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

Refer to the sticky "Starting C" which gives the links to OPengL tutorials which is a third party API for 3D graphics purposes.

http://www.daniweb.com/techtalkforums/thread50370.html

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

Hmm... I think that the lines of include code

#include <gl\gl.h>
#include <gl\glaux.h>
#include <gl\glu.h>

should actually be

#include <gl/gl.h>
#include <gl/glaux.h>
#include <gl/glu.h>

Try this and see if this works.
Bye.

Regards,
~s.o.s~