I am new to Dev-C++, but i am no noob to the C++ language. I was taught C++ on Metroworks Codewarrior and am no longer able to use that compiler, through a little bit of toying around I learned that Dev-C++ is a world different from Metroworks (if not, then close).On to my question... I have some libraries I really like that i would like to convert to the Dev but at the same time create new libraries from scratch to use in future programs, could someone help me convert on of my libraries (i will post it also) and give me a basic outline of a good Dev-C++ library that i can call my own and customize w/out end?
BTW: I am running Dev-C++ 4.9.8.0 and Windows 98 SE
a73h_L337lib.h:
ifndef a73h_L337lib
define a73h_L337lib
void randomnum(int high,int low, int &num1, int &num2);
void ending();
void randomHP(int high,int low, int &HP);
void randomMP(int high,int low, int &MP);
endif
a73h_L337lib.cpp:
include "a73h_L337lib.h"
include <time>
include <iostream>
include <stdlib>
void randomnum(int high, int low, int &num1, int &num2){
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
num1=rand()%(high-low+1)+low;
num2=rand()%(high-low+1)+low;
}
"and give me a basic outline of a good Dev-C++ library that i can call my own and customize w/out end?"
Sounds to me like you were taught bad C++. Code is code, libraries are a tool issue. A quality library will be a quality library regardless of the tools used to craft it. No one can give you a magic description for a "basic outline" that will ever be valid.
I can't believe that that code compiles with Code Warrior. Shift the headers 'time' and 'stdlib' to the actual 'ctime' and 'cstdlib'.
Soma
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-01-25
I am not sure about all the irrelevant blurb, the only relevant part seems to be the title of post, and to that end:
File->New->Project->Static Library, select language, and project name (used as library name, prefix it "lib" to conform with the GNU convention of libXXX.a). Add your sourced to teh project (See project menu or Project pane context menu), and build. The result will be a librray archive (.a) file that you can use just like any other.
C and C++ are standardised languages, and even before standardisation variations between compilers are not that great (original pre-1989 K&R C excepted). So I am not sure how you can say that "Dev-C++ is a world different from Metroworks" unless you are only referring to teh IDEs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-01-25
I am not sure about all the irrelevant blurb, the only relevant part seems to be the title of post, and to that end:
File->New->Project->Static Library, select language, and project name (used as library name, prefix it "lib" to conform with the GNU convention of libXXX.a). Add your sourced to the project (See project menu or Project pane context menu), and build. The result will be a library archive (.a) file that you can use just like any other.
C and C++ are standardised languages, and even before standardisation variations between compilers are not that great (original pre-1989 K&R C excepted). So I am not sure how you can say that "Dev-C++ is a world different from Metroworks" unless you are only referring to the IDEs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanx, that helped.
wat i was taught was basic and learned in high school(which i am still in, high school), not all of it is the original code i used for the class (previous attempt to compile). and again i thank ye for lending me your intellect.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am new to Dev-C++, but i am no noob to the C++ language. I was taught C++ on Metroworks Codewarrior and am no longer able to use that compiler, through a little bit of toying around I learned that Dev-C++ is a world different from Metroworks (if not, then close).On to my question... I have some libraries I really like that i would like to convert to the Dev but at the same time create new libraries from scratch to use in future programs, could someone help me convert on of my libraries (i will post it also) and give me a basic outline of a good Dev-C++ library that i can call my own and customize w/out end?
BTW: I am running Dev-C++ 4.9.8.0 and Windows 98 SE
a73h_L337lib.h:
ifndef a73h_L337lib
define a73h_L337lib
void randomnum(int high,int low, int &num1, int &num2);
void ending();
void randomHP(int high,int low, int &HP);
void randomMP(int high,int low, int &MP);
endif
a73h_L337lib.cpp:
include "a73h_L337lib.h"
include <time>
include <iostream>
include <stdlib>
void randomnum(int high, int low, int &num1, int &num2){
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
num1=rand()%(high-low+1)+low;
num2=rand()%(high-low+1)+low;
}
void ending(){
}
void randomHP (int high,int low,int &HP){
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
HP=rand()%(high-low+1)+low;
}
void randomMP (int high,int low,int &MP){
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
MP=rand()%(high-low+1)+low;
}
srand() in all the functions looks bad. Just leave the seeding to the user of the function.
Have you thought what would happen if you called your random number functions several times a second?
"and give me a basic outline of a good Dev-C++ library that i can call my own and customize w/out end?"
Sounds to me like you were taught bad C++. Code is code, libraries are a tool issue. A quality library will be a quality library regardless of the tools used to craft it. No one can give you a magic description for a "basic outline" that will ever be valid.
I can't believe that that code compiles with Code Warrior. Shift the headers 'time' and 'stdlib' to the actual 'ctime' and 'cstdlib'.
Soma
I am not sure about all the irrelevant blurb, the only relevant part seems to be the title of post, and to that end:
File->New->Project->Static Library, select language, and project name (used as library name, prefix it "lib" to conform with the GNU convention of libXXX.a). Add your sourced to teh project (See project menu or Project pane context menu), and build. The result will be a librray archive (.a) file that you can use just like any other.
C and C++ are standardised languages, and even before standardisation variations between compilers are not that great (original pre-1989 K&R C excepted). So I am not sure how you can say that "Dev-C++ is a world different from Metroworks" unless you are only referring to teh IDEs.
I am not sure about all the irrelevant blurb, the only relevant part seems to be the title of post, and to that end:
File->New->Project->Static Library, select language, and project name (used as library name, prefix it "lib" to conform with the GNU convention of libXXX.a). Add your sourced to the project (See project menu or Project pane context menu), and build. The result will be a library archive (.a) file that you can use just like any other.
C and C++ are standardised languages, and even before standardisation variations between compilers are not that great (original pre-1989 K&R C excepted). So I am not sure how you can say that "Dev-C++ is a world different from Metroworks" unless you are only referring to the IDEs.
thanx, that helped.
wat i was taught was basic and learned in high school(which i am still in, high school), not all of it is the original code i used for the class (previous attempt to compile). and again i thank ye for lending me your intellect.