now i combine stack,queue together...i wanna seperate stack to stack.h and queue.h and another for .cpp
can show me how?? from my program...
i hv seperate it..hv many errors
What are the errors? Post the code or attach the files.
now i combine stack,queue together...i wanna seperate stack to stack.h and queue.h and another for .cpp
can show me how?? from my program...
i hv seperate it..hv many errors
What are the errors? Post the code or attach the files.
ansiString is Borland's C++ builder string class. you can use its SubString method to remove the space. I don't use that compiler, but googled a bit and found this in about 5 seconds.
show me at least example..then i can only can do it
Haven't you read your own thread :cry: Or maybe you didn't comprehend what you read. The example is in post #2. I'm not about to rewrite it.
how to make stack.h,queue.h,palindrome.cpp seperate files....??
With those filename, they are already separate files, so I don't understand your question.
This program was written for something else, but I added the code to do it in full screen (but its not really full screen on XP, just as big as the cmd prompt window can get :eek: )
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <Wincon.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cctype>
using namespace std;
int main()
{
HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd,SW_SHOWMAXIMIZED);
string str = "UPPER-CASE";
transform(str.begin(),str.end(),str.begin(),(int(*)(int))std::tolower);
cout << str << endl;
cin.ignore();
return 0;
}
my program is C++ rite???
Yes, it is.
mind show me where should i add the transform function??
I already told you. You can do your own copy/paste, my fingers can't ready your keyboard :eek:
There are lots of c++ classes on the net. Some are at www.codeproject.com, just use its search engine to search for odbc, or google for "odbc c++ classes"
Forcing the value of a pointer is a bit dirty
md: In MS-Windows and *nix it will most probably crash the program because the operating systems do not allow programs to access memory addresses that way. Gone are the days of MS-DOS when a program could just write to random memory addresses.
Some 16-bit MS-DOS compilers (e.g. Turbo C) are still available for free.
1. start out by replacing that C-style character array named "string" with a c++ string class and name it something else, such as line. You are writing a c++ program, so use c++ classes whenever possible. Not that it can't be done with C, just that it's more consistent.
2. replace cin.getline() with getline(cin,line)
3. paste that transform line after the getline() in #2 above
After making the above changes your program seems to work ok for the strings I entered.
your compiler is correct. print() is not accessible outside Bird class because of private inherentence. It can only be called from within Bird class just like any other private member.
I see nothing in your code to cause that coloring behavior. list is not a keyword unless you include <list> c++ header file. Must be your os or the text editor you are using to display the output. c++ does not know anything at all about colors.
read your textbook about scanf() -- what does it return? It certainly does not return price, as indicated by your code. Your use of scanf() return value is wrong.
I've read your question 3 times and the program once, but I still fail to understand the question. Yellow ? Where do you see the output colored in yellow? Must be your monitor doing that.
I'm not terribly STL-savvy, what is this error telling me?
//Error E2285 testpp.cpp 11: Could not find a match for 'transform<InputIterator1,InputIterator2,OutputIterator,BinaryOperation>(char *,char *,char *,charT (*)(charT,const locale &))' in function main()
...while I continue searching for an answer on my own...
Dev-C++ (gcc) has a compiler bug
How do i change the capital letter to smaller letter as above output example
use tolower() to convert a character to lower-case. It only works on one character, so if you want to convert a whole string to lower case you have to create a loop to iterate each character. Here is a c++ example.
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cctype>
using namespace std;
int main()
{
string str = "UPPER-CASE";
transform(str.begin(),str.end(),str.begin(),tolower);
cout << str << endl;
return 0;
}
parentheses are required as shown in previous posts.
you mean you want someone to "do" your homework for you, not to "help" you do it. You don't (won't) learn a thing that way. Give it your best shot, read your textbook, practice, then post code and questions that give you problems. You get it all free right here.
all file i/o functions on MS-DOS computers eventually call the win32 api functions such as ReadFile(), WriteFile(), CreateFile() etc.
mixing c and c++ file operations is undesirable, but not something that will crash the program. Probably the reason it crashed is that there is no check to see if the file was opened successfully. You can't just assume that. The second reason is that c is defined as char, but getc() returns an int. change c to an int and it should detect EOF correctly.
it will compile, but dereferencing a null pointer like that will often (but maybe not always) crash the program -- it's undefined behavior. In the case of c++ classes, the function will be called with an invalid "this" pointer and any attempt to reference or use class objects will also result in undefined behavior. So "it works" is all relative to this undefined behavior, and won't "work" very long!
visually verify the data file is correct -- no blank lines and every line has the same format.
const int maxcols=4;
Count the number of t's and f's in one of those lines. How many did you count? Less than 4 or more than 4. maxcols needs to be a minimum of (number of t's and f's) + 1 for the character array's null-terminator.
-86, is that a compile-time error or runtime error?
1. make sure maxstudents is not greater than the number of lines in the data file. There are better (and easier) ways to read the file without knowing the number of lines beforehand, but get this working first and you can refine your program later.
2. The output line is incorrect. It should look like this:
cout<<quiz[r]<<"\t";
If you still have problems after making the changes, repost your program. But those should fix it, at least it did in my version that I don't intend to post :)
Can c++ make programs that you can install onto a computer like you would software you buy from a shop. Basically does it allow you to make the installer setup stuff. Even if you program is very very basic.
Is there software that does this for you and you just paste your code into it and it makes the installer for you. In pascal the compiler just churns out an exe that when you double click on it runs the code in dos.
Yes you could write your own installer, but you don't have to. You can buy ($$$) InstallShield which is probably the most popular installer. I think Microsoft also has an installer that can be used (not sure about that though). I wouldn't be supprised if there are shareware installers too.
What the hell in gods name is visual studio.net and what can it do. There are so many programs that have the visual word at the beginning of them. e.g visual c++
and finally are there any advantages of using c++ over VB and vice versa.
Visual Studio .NET produces two types or programs -- managed and unmanaged.
Unmanaged programs are just like any other c++ program that compiles to *.exe program.
Managed programs can be written with all its language parts in the same program -- write parts of it with VB, C# and/or C++. You can mix and match as you please because they are all compiled down to some …
where is the third column? Your program needs only one loop. maxcols is too small -- needs to be 1 more than the number of t/f test scores.
for (int c = 0; c<maxstudents; c++)
{
infile>>studentid[c] >> quiz[c];
}
my company forbids use of goto, and it is strictly enforced during peer review. Yes, programmers are NOT free to just code any way they wish -- there are coding standards and the code is periodically reviewed to insure those standards are followed. There is absolutely never justification for its (goto) use.
hint: use floats, not ints as variable types.
post the contents of the data file, or just a few lines if its too large. Your program is written to expect all student ids to be listed first, followed by all answers and lastly the total number correct for each student. But I doubt that is how they appear in the data file.
It is indeed a parameter passing technique -- there are only two ways to pass something, by value and by reference. Pass by reference can be done in one of two ways -- a pointer (C) or reference operator (C++). The three differences I can think of
1. use of dot or pointer operators within the receiving function
void foo(int* n)
{
*n = 0;
}
void foo(int& n)
{
n = 0;
}
2. use of '&' operator inside the passing function
int main()
{
int n;
foo(&n);
foo(n);
return 0;
}
3. They can be overloaded functions as shown in the examples above.
Otherwise, the dot and pointer operator compile down to the same identical code. Its all really just a matter of programmer preference.
how to do that depends on the operating system. You can either use operating system-specific GUI drawing functions, or some SDK such as QT that is mostly os-independent. Either way, it will take several months to learn. There are some commercial graph packages you can buy -- some may even be free open source. You will have to google for them.
you are attempting to declare a function CalcDepr() within another function main(). You can't to that. Move all the code for CalcDepr() outside function main() and it will probably compile ok, unless of course there are other errors.
[edit]Nevermind -- Narue answered your question. Too bad we can't delete our own posts like I can on other boards :cry:
That is definitely NOT me. It may be someone from my same class.
read that other thread and use the same suggestions. Or do you want somebody to do your work for you?
if p were an array, then the initializer list would have to be in braces, not parentheses, like this
int p[] = {1,2,2,100};
But the above is entirely different than the code you originally posted.
the parameter to free() must be the same pointer that was returned by malloc(), calloc() or realloc(). Your program destroyed that pointer in the printf() statement.
Why don't you use array a just like any other array instead of using pointer arithemic
for (i=0; i<SIZE; i++)
a[i] = i * i;
for (i=0; i<SIZE; i++)
printf("%d\n", a[i]);
any idea?
Didn't you read my response? I already showed you two ways.
Well, it has nothing at all to do with MFC. You probably created a console application and tried to code a MS-Windows win32 api application. You will probably have to start all over and create the correct type of application (win32 application).
The first example could be shortened like this
string format(double Value, int nPrecision)
{
char buffer[100]; //Buffer where to store the resulting formatted string.
sprintf(buffer,"%0.*f",nPrecision,Value); //Print formatted data to a string
return (string)buffer;
}
or
string format(double Value, int nPrecision)
{
stringstream s;
s.width(nPrecision);
s << Value;
return s.str();
}
double quotes mean a null-terminated string, single quotes is a single character. Replace the double quotes in the if statement to single quotes.
if ( term1[1] == '(' )
get rid of that silly semicolon ';' at the end of the if statement. The next line, print(...) need a semicolon at the end.
if you know the format, then its pretty easy
string date = "01/02/2005"; // 1 Feb 2005
int month = atoi(date.substr(3,2).c_str());
// do day and year similar to above
I used size_t because that's how malloc() is prototyped. http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html
>>If it can't, then how will your compiler ever be able to generate a run-time assertion?
Just because malloc accepts a size_t value doesn't mean the memory manager can handle a request for the full extent of size_t's range at any given time, or even at all.:
but that's not the same thing as your previous statement. Previously you stated an assertion was raised if a value greater than size_t was passed. I said that's impossible. Nobody mentioned passing values less than size_t.
I think I already mentioned it is up to the compiler to interpret null pointers for the destination operating system. So I don't see any differences of opinion. you are making a really trivel distinction that most of us mortals don't need to worry about. True, its not trivel to an embedded programmer, but this thread is not about embedded programming.
that still doesn't guarantee that your system is 32-bit. ;)
Actually, it says nothing at all about the system. I have a new 64-bit system and sizeof(int) is still 32 because that is what the compiler said it is, not the system. It would be impossible to run 32-bit programs on a 64-bit machine otherwise. ;)
If 0 is good enough for Bjarne, then it's good enough for me. Its up to the compiler to interpret that 0 for the target operating system -- programmers just need to put a 0 there. The language would not be very portable if the programmer had to worry about whether or not any given implementation did or did not recognize address 0 as a valid address, or even if it had an address 0. That's the compiler's job.
> there's a run-time assertion if the allocation size exceeds a certain limit, and 4294967295 is beyond that limit.
The parameter to malloc is a size_t (on my compiler it is defined as unsigned long). So how in the world can you ever pass that function a value greater than what can be stored in size_t (that is, the function will never receive a value greater than that).
If it can't, then how will your compiler ever be able to generate a run-time assertion? Or do you really mean the compiler generates a compile-time warning or error? :?:
>I think the longest string that can be made in C or C++ is the maximum value of an integer (as defined by size_t).
That's a reasonable assumption, but why not just call string::max_size() and be sure?
The op didn't mention using std::string class, so I assumed it was for character arrays.
I understand the confusion because I said "A NULL pointer ALWAYS has absolute address 0" which is incorrect. The pointer does not have an address of 0, its the value stored at the pointer's address which is 0. So I apologize for any confusion this may have caused. The term "null pointer" always referrs to the value stored at the pointer's address, which is 0 when NULL.
passing an object by value calls the copy constructor because a new copy is created -- and that would mean an infinite recursion. Also, it always faster to pass c++ class objects by reference than by value.
.or does it mean '\0' and 0 are same
Yes, '\0' and 0 are the same.