Summary execution by firing squad isn't inhuman.
Many including the USSC would disagree. Personally I don't think so either, but I don't have a vote.
Summary execution by firing squad isn't inhuman.
Many including the USSC would disagree. Personally I don't think so either, but I don't have a vote.
see its erase() method
If you create a windows project (as opposed to a console program) just remove the winmain() that the IDE created and put it in the library. That's all there is to it. I assume you downloaded the Windows Platform SDK and installed it according to the instructions on M$ site. If you didn't then you can't create a windows program.
Here is how to get a list of processes in MS-Windows. Don't know how to get the rest of the info you need.
after you enter 0 then the recursion unwinds and only the line that prints the value is executed. That is done in the reverse order that they were called.
>>If the number isn't zero you call the function again and then output the number
No it doesn't work quite that way. The printing doesn't start until after returns from the recursion.
Sorry towhoe but I can't help you any more this evening. I suspect this assignment is way beyond your ability to complete. you are just asking too many newbe questions and your assignment is for someone who already has some fundamental understanding of programming concepts. It's difficult to believe your teacher/school would give a first semester student an assignment that is so advanced.
>>with the other it worked fine. whats wrong?
Look everywhere in your program for getmeters and you will see the differences. That function must be passed one parameter by reference. And NO -- it did not work fine because the function must have one parameter.
>>your program is nearly complete
After re-reading the program requirements you are still pretty far from having it finished. But you need to get this to compile cleanly before continuing.
The getmeters() that I posted is wrong. It should return void and take a parameter by reference, such as void getmeters(int& meters);
After that you need to create the two tables that were in the program requirements.
>>It doesnt do anything like it, where did i go wrong?
You are right -- you have not implemented that part yet. What you need are two int arrays to hold the values your teacher wants. Below I just put in dummy numbers -- you need to put in the correct value. You can find them in any conversion calculator on the web.
int meters_to_yards[] = {0,1,2,3 ...}; // you have to use correct values here
int yards_to_meters[] = {0,1,2,3 ...}; // you have to use correct values here
>>what is the fatal error im getting and how do i resolve that?
That means that there were previous compile errors -- you can just ignore that line because it will go away after you get all the other errors fixed.
>>double getmeters(int);
Your post #6 does not have that line.
>>Nothing is working.
you are underestimating yourself, probably because you are so frustrated.
your program is nearly complete -- all you have to really to is add that one function. Here is your program formatted correctly.
#include <iostream>
using std::cout;
using std::endl;
double y2m=1.09361329834;
double m2y=0.9144;
double getyards(int);
double getmeters();
int main ()
{
int i;
double meters;
for (i=5; i<=100; i=i+5)
{
double yards = getyards(i);
cout << i << yards << endl;
}
for (i=5; i<=100; i=i+5)
{
meters=getmeters();
cout << i << meters <<endl;
}
return 0;
}
double getyards (int x)
{
return (x*m2y);
}
double getmeters()
{
return 0;
}
using code tags here is pretty simple, [code=c++] // your code goes here
[/code]
And don't use tabs in your code because they will not look right when posted here even though they may look ok on your computer screen. Depending on what compiler you are using the compiler may have option to replace tabs with spaces. If not, then just hit the space bar on your keyboard instead of the tab key.
>>I dont know how to write the function for it, everything ive tried comes up with an error
post what you tried.
>>Sorry I didnt format right. I didnt know how
Here is a short tutorial on how to format your program. You should probably bookmark it so that you can refer to it often until you have it down in your head.
>>error LNK2019: unresolved external symbol "double __cdecl getmeters(void)" (?getmeters@@YANXZ) referenced in function _main
That error message is telling you that the compiler can not find a function named getmeters that does not have any parameters. You prototyped it ok on line 8 and called it on line 21, but nowhere did you actually write that function.
>>I dont know how to do that.
you don't know how to do what? I reformatted your code in another thread for free, I'm not going to do it again every time you post something. Go back to your other thread and see how I formatted it. Also read the information in the link that someone else posted. If you are not going to read the responses to the threads then there is not much we can do for you.
>>please give me something to go on
I did. learn to read the threads.
>>Our book is horrible
Maybe, but you have to read it.
line 21: meters is a double, getmeters is a function. you can not assign a function to a double. But what you can do is assign the return value of the function to a double like this: meters=getmeters();
line 22: delete that line because it has wrong parameters (see function prototype on line 8) and doesn't do anything.
line 24: why are you printing the address of meters instead of its value ?
pay closer attention to the open and closing braces { and } -- they must match. For every { there must be a corresponding }. Don't be so careless in your coding.
develop it with a GUI, and there are lots of ways to do that. Some depend on the operating system while others are independent of the operating system. You can get free ones and you can pay several thousand $$ for others. But if you are new to c++ (such as 1st year student) then all of them are probably way beyond your current ability to grasp.
>>i am a new viciter of this site
lier -- you already have 31 posts. :)
Visual C++ is a compiler, not a language.
>>in what way it will be different from each ther in oth program
None. VC++ is just the name of a compiler that will compiler normal C++ programs.
void foo()
{
// ask for input
// if input != 0 do recursion
// print the number entered in this instance of the function and print a comma after it
}
>>Better?
Absolutely. :) But I didn't know there were Ctrl+??? keystrokes for bold and italic either.
That's not hard to do, but you have to be very careful of getting stack overflow errors. And that's pretty each to do with recursive functions.
>>I'm stumped again
Do you know what a recursive function is? If not then read about them in your text book. Its simply a function that calls itself.
int foo()
{
foo(); // recursion
}
Don't compile or run the above because it will kill your os.
>>I'm curious why you said to move esi to edx?
esi is a 32-bit register and can only be copied to another 32-bit register.
>>Also could you explain a little about dl?
Its just an 8-bit register just like al. Only eax, ebx, ecx, edx contain 32-bit, 16-bit and 8-bit registers. And you have to use an 8-bit register to do anything with just one byte of memory.
>>Of course, you cannot do this with columns. That's a problem for another day
Sure you can -- if what you mean is you can not sort by columns rather than by rows. Its possible to sort all rows by a specific column or all columns by a specific row. Might not make much sense to do it, but it is possible.
> First of all, for code tags a keystroke would help a whole lot.
I agree, but it would be hard to code. A new version of vBulletin with a different backend to the editor is being released sometime within the next month. I'll look into it then.
Huh! for code tags a keystroke makes no sense at all. What in the world is that supposed to mean anyway. I think someone needs an English refresher with that runon sentence.
a keystroke would help a whole lot. would help what a whole lot ? It that talking about a hotkey, such as press Ctrl+A and it'll post the code tags around the code ?
My os is XP, I don't know what updates, and can't look right now.
I will try to install it again.Also, does the express edition allow files to be compiled into working executables, or just run as processes?
Yes it will create the executable. It has the same compiler as all other versions of VC++, the difference is the additional bells-and-whistles.
you need to change the sort function to sort one column of a two-dimensional array
void sortarrray(int t[][10], int NumRows, int ColToSort)
{
// sort code here
}
>>it also asks me to do a binary search...would it change if its a 2d array?
Very similar to the way you would sort it. Start out using the normal binary search algorithm for a one-dimensional array then expand it to use a 2-dimensional array that searches only one of the columns.
I have done this (well, tried to). For some reason, the express version of vc++ simply will not compile, debug, or anything.
You installed it incorrectly. What version of Windows are you using anyway ?
I will change the long long values throughout to size_t or the equivelant. As you may notice I am trying to keep this without any required importations. So if size_t is the same as just long, I'll use long.
size_t is normally (but not always) defined as unsigned int
If it is defined somewhere do you know where?
depends on the compiler.
line 29: byte is a reserved word that means one byte and you are attepting to add a 16-bit register value to it. You will probably have to use a different general register to do it
mov edx,esi
add byte[eax], dl
But when you do that you might as well replace esi with edx everywhere in that loop to avoid repeated copying.
The problem is that you are recursively including A.hpp and B.hpp. So solve the problem, just pre-declare the classes
#ifndef B_HPP_
#define B_HPP_
class A;
#include "A.hpp"
class B
{
public:
B();
virtual ~B();
private:
A* apt;
};
#endif /*B_HPP_*/
Dev-C++ compiles that without any errors. But VC++ 2005 shows several errors that Dev-C++ did not catch.
d:\dvlp\tester\tester\bcstring.h(144) : warning C4138: '*/' found outside of comment
d:\dvlp\tester\tester\bcstring.h(635) : warning C4800: '__int64' : forcing value to bool 'true' or 'false' (performance warning)
d:\dvlp\tester\tester\bcstring.h(882) : warning C4244: 'initializing' : conversion from '__int64' to 'size_t', possible loss of data
d:\dvlp\tester\tester\tester.cpp(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\dvlp\tester\tester\tester.cpp(42) : error C2039: 'ToFile' : is not a member of 'bcstring'
d:\dvlp\tester\tester\bcstring.h(94) : see declaration of 'bcstring'
d:\dvlp\tester\tester\tester.cpp(45) : error C2039: 'ToFile' : is not a member of 'bcstring'
d:\dvlp\tester\tester\bcstring.h(94) : see declaration of 'bcstring'
Generating Code...
Build log was saved at "file://d:\dvlp\tester\tester\Debug\BuildLog.htm"
tester - 4 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The error on line 635 can be corrected by redefining keepGoing to be long long instead of bool
I don't know how you can correct the error on line 882 -- the new operator takes a size_t object and you are attempting to pass a long long. You can typecast it to size_t but might loose precision if the value is more than what a size_t can hold.
I think you can figure out the rest of the errors.
My suggestion is to scrap Dev-C++ and download free VC++ 2005 Express because it catches more errors and has a really good debugger that …
Just tried it again, and WinZip reports this error
End-of-central-directory signature not found. Either this file is not a Zip file, or it constitutes one disk of a multi-part Zip file
[edit]Ok -- tried it again and this time it worked ok [/edit]
Illegal aliens, I say send them into the military and let them prove themselves as good citizens in the worst spots around the world.
Many non-USA citizens do just that because its a fast track to US citizenship. I don't know about illegals, but anyone who spends about two years in US military is almost guarenteed citizenship when discharged, assuming there is nothing else to prevent it such as failing a criminal background check.
Some teachers still use the ancient Turbo C++ because they don't know any better and are just too stupid to upgrade to newer FREE compilers. There is no vaid excuses for any university or college of higher learning in USA and most european nations to do that. Then they have the nerve to charge students $100.00 or so for 20 year old c++ textbooks. Shameful.
Note: the file you attached to your thread is not readable by WinZip but the file at the web site is ok. Are they supposed to be the same ?
I have Dev-C++ version 4.9.9.2 and using the project file in your zip file the compiler produced a flood of errors and warnings. You need to go through bcstring.h and fix them all one at a time.
>>I have spent about 2 weeks trying to solve this error
You are a lot more patient than most programmers :) Save yourself a lot of headaches and NEVER EVER assume warnings are ok -- in most cases they are really errors. Only after getting a completly clean compile can you even begin to debug the program.
Your formatting is terrible and makes it difficult to follow. Here is the same program reformatted the way it should be formatted. Note that it is very easy to spot mis-matched braces when formatted this way. Also, don't mix using tabs and spaces because they will get screwed up when you post it here.
#include<iostream>
using namespace std;
int main()
{
int n,i=3;
cout<<"please enter number to see weither it is a prime one or not"<<endl;
cin>>n;
if(n==2||n==3)
{
cout<<n<<"is prime number"<<endl;
}
else if(n%2==0)
{
cout<<n<<"\t is not prime"<<endl;
}
else
{
for(i=3;i<n;i+=2)
{
if(n%i==0)
{
cout<<n<<"\t is not a prime number"<<endl;break;
}
else if (i=n-1)
{
cout<<n<<"is a prime number"<<endl;
}
}
}
return 0;
}
how do I do that , that is submit whatnot on my on thread ?
Just hit the Start New Thread button here.
how do I create a calender program using c++?
If you were "smarter than a 5th grader" then you could just simply "copy" from the previous poster. But be aware that if he is also wrong you will have to post "I Antwane am NOT smarter than a 5th grader." and flunk out of school.
[edit]For those not in USA "Are You Smarter Than A 5th Grader" is a popular current TV game show where the contestent can win up to $1,000,000.00 for answering ten 1st through 5th grade questions.[/edit]
@ Ancient DragonCome at my home India and enjoy the Indian food. :)
Might be easier to just email or PM it to me :)
good point -- done.
Is there a way to change the title of the thread so that it more accurately reflects the contents?
Yes, but why now that it's been marked solved ?
So...what/where is the method you've tried? Without providing you the answer...here is a basic outline:
I guess you need to learn to read too. Problem already solved in another thread.
Yes, I agree that is a much better solution. With vector or list there is no need for stdarg.h or for writing an infinite amount of templates.
Now if someone would just delete those obnoxious posts!
>>is that correct?
yes
> There are no compilers that support it
the output that i posted is with the code compiled by gcc 4.3 today; they are not my visualization of how it would look like in 2020.
You are fortunate -- I tried it with VC++ 2005 Express and Dev-D++ Version 4.9.9.2 and they both puked out lots of errors.
> we still have to resort to stdarg.h to get variable argument functions you may have to. i do not. even without gcc 4.3.
Apparently I'm not alone! I suspect you think everyone should abandon their compilers and get gcc 4.3 (note: I'm not trying to insult you here, just poking a little fun) :)
Already did -- see the previous thead you started this morning.
line 27: what is that length function you are calling? In your program number is the length of the array so there is no need to call another function just to get that. You don't need total_facts at all, just replace it with number on line 28.
There really is no need for that array at all. Just use the loop counter on line 29 because it contains the same values as that array.
This is all you need
int n = 1;
for(int i = 1; i <= number; i++)
{
n *= i;
}
hmm, summary execution does sound like a realistic suggestion.
Worked in the 1800s, can't see why it wouldn't work today.
Yes it would work, but we'd never do it because of "cruel and inhuman punishment" clause. USSC is looking into abolishing leathel injection so its not likely they'd approve executions. Now then, the guillotine might be a different matter :)
>
but there is good news. c++ programmers will never have to use the unsafe and error-prone <cstdarg> ; c++0x has a solution. using variadic templates, we can write a typesafe function taking an arbitrary number of arguments of arbitrary types. http://en.wikipedia.org/wiki/C++0x#Variadic_templateshere is how you would write largest_of a variable number of values in c++0x.
#include <iostream> #include <string> // compile with gcc 4.3 with the -std=c++0x switch template< typename T > inline const T& largest_of( const T& a, const T& b ) { return a>b ? a : b ; } template< typename T, typename ...REST > inline const T& largest_of( const T& first, const REST&... rest... ) { return largest_of( first, largest_of( rest... ) ) ; } int main() { std::cout << largest_of( 1, 9, 2, 8, 3, 7, 4, 6, 5 ) << '\n' ; std::cout << largest_of( 5.3, 8.9, -3.2, 17.8, 4.2, 7.0 ) << '\n' ; const std::string s1("abc"), s2("2345"), s3("vufuk"), s4("ffyfyu") ; std::cout << largest_of( s1, s2, s3, s4 ) << '\n' ; } /** >g++43 -Wall -std=c++0x -pedantic -Werror largest_of.cc && ./a.out 9 17.8 vufuk */
Greate news for the graduating Class of 2020. There are no compilers that support it since the standards have not been approved yet so we still have to resort to stdarg.h to get variable argument functions.
please repost your current code. And use code tags this time.
fix the error messages on at a time, then recompile after each fix. For example the first one says error C3861: 'getyards': identifier not found. That means the compiler does not know what getyards is on line 17. But look on line 25 -- you gave it the wrong function name, and need to rename it to getyards. Then you have to either move the function from line 25 to line 7 or on line 7 prototype the function. This is the prototype you should put on line 7 if you don't want to move the function from line 25 to line 7.
double getyards(int);
Another problem you have: don't attempt to write so much code before compiling because (1) the program you posted is just filled with syntax errors, and (2) you will get fludded with compile errors that take ten times as long to fix. You should only write two or three lines before compiling. Fix all errors and warnings, then write a few more lines of code.