Tux4life is right, you can't delete one element of an array in C(++). Either use a vector or do as tux4life said.
Yeah, a vector is also a very good solution :)
Tux4life is right, you can't delete one element of an array in C(++). Either use a vector or do as tux4life said.
Yeah, a vector is also a very good solution :)
ok, but this is an example of C++ or C?
Sorry, it's a C example, I've changed the syntax in my code ...
E.g: in your function Class_Grade()
you're want to access the variable grade1, grade2, grade3 which you previously declared in the main-function, but this isn't allowed in C, you should pass these values as an argument, this is an example of a modified Class_Grade() function:
int Class_Grade()
{
int g1, g2, g3, gradeavg;
printf("Please enter Class grade");
scanf("%d%d%d",&g1,&g2,&g3);
gradeavg=(g1+g2+g3)/3;
/* Put g1+g2+g3 between brackets because of the algebraic rules of math */
return gradeavg;
}
{
char studentname[31];
}
Why are you declaring studentname as a global variable ?
Just add char studentname[31];
to the beginning of your main function ...
Is that better?
Yeah, that's a lot better :) ...
Will there be new things I have to add to my projects?
Check out the Allegro documentation and the changelog :) ...
Here's the link for a precompiled version of the 'Allegro 4.9.9.1.7' :
http://www.2shared.com/file/5412050/85f47e8/precompiled_allegro-4991.html
Here's some additional info:
> Build for DirectX 9 (Windows)
> Using the MinGW-compiler
> And ... CMake
Your main() function misses a '}' at the end, your functions haven't specified their return value ...
If your function isn't returning a value then you should declare it as void: void [I]yourfunction[/I]
Your main function doesn't return a value, declare it as int main()
:
int main(void)
{
/* The code of your main function here */
return 0;
}
It's looking for a compiler called g++, but comes up with an error because it can't find it. I think the right one that really does exist is the gcc compiler. If so how do I tell it to use that one?
Did you set the MINGDIR and PATH environment variables correctly ?
I don't think it's possible in your way, you should declare an array of pointers instead if you want to delete individual elements ...
Edit::
int n = 5;
Classname ** ptr_to_array = new Classname * [n];
Now you should use a for loop to assign objects to the pointers ...
(You should also use a for-loop to destruct it)
I don't think it's possible in your way, you should declare an array of pointers instead if you want to delete individual elements ...
You don't have to type the path name after cmake, cmake is used to generate the makefiles :) ...
Use: cmake -G "MinGW Makefiles"
Edit:: I'm trying to precompile it for you ...
That is not intended for a 'perfect' system, it's only a disclaimer. If you want to bypass it, it's your problem, you're violating the law. Look the little legend on every drug, that doesn't avoid to swallow a pill by a minor.
Agreed, but I only wanted to mention that this system isn't going to prevent anyone to view your site's contents ...
It's always nice if you can solve your problems yourself, congratz :) ...
(It was indeed a beginners mistake, but never mind it can overcome anyone)
void Class_Grade()
{
printf("Please enter Class grade")
scanf("%d%d%d",&grade1,&grade2,&grade3)
void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
has to be
void Class_Grade()
{
printf("Please enter Class grade")
scanf("%d%d%d",&grade1,&grade2,&grade3)
}
void Exam_grade()
{
printf("Please enter Exam grade");
scanf("%d%d",&exam1,&exam2);
}
Remember that a function's body always has to be between a '{' and a '}' ...
its confusing me
What's so confusing to you?
I would recommend to create a design of what your application has to be able to do and how you're going to achieve this before going onto the real coding part ...
For legal purposes?
You can quickly bypass this mechanisms, if you really want to be sure you should use credit card validation or something (but keep in mind that this will discourage people to continue) ...
There is a legal way to create your own xp with a program named
Nlite for xp,press the down link :D
http://www.nliteos.com/download.html
Yeah, that's right but Microsoft doesn't offer support for these customized editions (but I don't know if you need it) ...
that is where i reach in the code, i need help and advice as to what to do next, to write it.
If your program has to deal with multiple students' information I would use structures (structs) to store all the information related to them ...
That's doable with simple conditionals. The most important field is year. We assume if is not > 1991 or 91. You wan to check boundaries, also use strtotime('-18 years')
I know, but it isn't pretty for the user to each time select his day of birth, then the month and thereafter the year ...
how do I change it to codeBlocks MinGW for the generator?
I don't understand what you mean with this ...
> Is this your whole code as it won't compile using any compiler ?
> Can you please be more specific in what you need help with ?
Why don't you just ask for his age (in years) instead ?
Is this actually your whole code as I can't seem to find the following functions:
> introduce();
> MainMenu();
> Input();
> errorCheck_num (input);
> show_error (sel_MainMenu);
> initialize_body (matrix);
> load (axeman, defender, archer, spearman, rouge);
In the code you posted, the main-function is missing a '}' at the end ...
If this is C++ code you should rename your files to main.cpp, subfunction.cpp and header.h, this will reduce the errors you're having ...
Yup, first read the forum rules and by the way people here usually don't respond to questions like: 'Please I want someone to help me'
You need to show us what you've done so far (forum rules), it's a nice assignment and it isn't too difficult, so give it a shot, ask specific questions about what exactly you don't understand and we'll help you :) to get a step nearer to the solution ...
OK, can you please attach your code to this thread ?
Unless its a volume licence edition and your campus agreement allows you to do that
Agreed, but you don't know this so I would just refer him to some kind of imaging solution ...
struct AXEMAN axeman; struct DEFENDER defender; struct ARCHER archer; struct ROUGE rouge; struct SPEARMAN spearman;
In C++ you don't have to supply the 'struct' word each time before you declare a struct-variable, though it's still allowed to do so, you can save some typing :) ...
Edit:: I don't get what you mean, do you have compiler errors ? (please post them if so)
What I want to know is how do I set up and use a proxy to intercept the data files sent and then transfer the data to a file so it can be read?
Intercepting data, that's actually the base of a firewall :) ...
Edit:: The following post is maybe what you're looking for (if you're using Windows): http://www.daniweb.com/forums/post784786-3.html
Edit:: This thread might be also useful for you :) ...
Yup, fstream's open-method only accepts a c-string as it's argument for the filename, so you'll have to convert your C++ string to a c-string first, you can easily do this by using the c_str()
method of the string class :) ...
Why? This is a suspicious activity, so we need a good reason before helping you with it.
Yeah, that's indeed a suspicious activity ...
Why does it need to be before logon?
Good question, it's much easier to implement if it's after the logon process :) ...
The following code should work:
void trim(string & s)
{
int strlen = s.length();
string tmp;
for(int i = 0; i < strlen; i++)
if(s[i] != ' ') tmp += s[i];
s = tmp;
}
> Why are you using a seperate counter 'k', you can just add something to a string by using the '+' operator ...
> Also avoid the use of system("pause");
(look here for the reasons), it's better to use cin.get();
instead ...
> Edit:: Your mistake is on the line where you say: if (copy[i] = ' ')
, it has to be if (copy[i] == ' ')
,
if you write if (copy[i] = ' ')
, copy[i]
will get the value ' '
, so the condition is always true, then you're running the continue
statement everytime which is just skipping to the next i
of the loop ...
But because the string copy is in the beginning (of your function) just an exact copy of the string s, the string s' value will remain the same :) ...
> Edit:: You're just overwriting string s, that causes a bad result, the last part of the 'trimmed' string will be the same as the original, but it still contains the whole (trimmed) expression ... ==> If someone can explain this in a better way please do so, as I'm not very good at it :P ...
I've attached the compiled file to this post ...
Enjoy it :P !!
tux4life
I tested this program and can confirm it works, but try running it with the wrong number of arguments (1 instead of 2) directly causes the program to crash, it's very 'crash-sensitive' ...
The program is also using 'old C++' code, for example old file handling using the FILE-pointer, etc. ...
So let's say: This program can be improved :)
I want to write the image to my CD or DVD and give it to the students.
That's indeed an illegal operation :) ...
I think Microsoft backup is able to do that, but it will be a more pleasant experience if you just use Acronis TrueImage which is designed for that purpose ...
It's just compiling fine with me (it gives a lot of warnings), I'm using the Borland Compiler ...
Edit:: Using the Microsoft C++ compiler (from Visual C++ 2008 Express Edition) I'm also getting this error ...
Java and JavaScripts are two different technologies, dude!
I made request to move this post in correct place...
Yup, he's confusing them, but I think PHP will probably his best bet to achieve something like this ...
May I suggest to move this to the PHP forum ?
Does it really have to be in Java, as it might be easier to do in PHP ...
Why are you using old casting ?
double test2_calc = [B](double)[/B]10/[B](double)[/B]5; const int test2 = [B](int)[/B]test2_calc;
It's a better practice to use the new casting operators to do conversion between datatypes:
double num = 5.23;
int num2 = [B]static_cast<int>([/B]num[B])[/B];
instead of the old ones:
double num = 5.23;
int num2 = [B](int)[/B]num;
Why don't you try it yourself first ?
> Get the input (the age) from the user
> Use some conditional statements ( if(condition) { /... }
) to check whether the script has to grant access or not
> Now you only need a command which redirects the user to a page in case the age validation has failed ...
Hope this helps :) !
Edit:: http://java.sun.com/j2se/1.4.2/docs/api/java/applet/AppletContext.html#showDocument(java.net.URL)
For the first case:
If your salary is 1000.23 it has to be 1000.25:
We multiply 1000.23 by 20, round it off to the nearest integer and divide it back by 20 :) ...
Edit:: In the second case (if your salary is 1000.26 and it has to rounded off to 1000.30): the Math.round function should work fine here !
Hope this helps !
Do you mean the application's startup path ?
> Application.ExecutablePath
or
> Application.StartupPath
should work :) ...
FILENAME.BAT
@ECHO OFF
fsutil.exe fsinfo statistics c:
Save this under filename.bat and it will run the requested command :) ...
Edit:: Replace filename with an appropriate filename ...
Did you read this:
http://www.daniweb.com/forums/announcement8-3.html
Apparently he didn't :P ...
You could use the 'list'-container from STL if you want linked lists ...
(Look here or here)
Or are you supposed to do without ?
Look at the following example:
Rational operator+(const Rational& left, const Rational& right)
{
Rational result;
/* Your code to add two Rationals here */
return result;
}
As part of an assignment I am creating a class to handle rationals with numerators and denominators, overloading the operators for cin and cout, as well as +-*/. So these are the functions for those operators, now where exactly should I include these in my class?
Rational addition(Rational a, Rational b){ Rational result = Rational((a.numerator()*b.denominator() + b.numerator()*a.denominator()), a.denominator()*b.denominator()); return result; } Rational subtraction(Rational a, Rational b){ Rational result = Rational((a.numerator()*b.denominator() - b.numerator()*a.denominator()), a.denominator()*b.denominator()); return result; } Rational multiplication((Rational a, Rational b){ Rational result = Rational(a.numerator()*b.numerator(), a.denominator()*b.denominator()); return result; } Rational division((Rational a, Rational b){ Rational result = Rational(a.numerator()*b.denominator(), a.denominator()*b.numerator()); return result; }
You aren't overloading any operators in this way ...