- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 32
- Posts with Upvotes
- 26
- Upvoting Members
- 7
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Datta, Dayadhvam, Damyata
non quasi imperans dico sed per aliorum sollicitudinem etiam vestrae caritatis ingenitum bonum conprobans
56 Posted Topics
Re: Make sure you created a Win32 project and not a console project (how to do that depends on your IDE) | |
Re: You shouldn't have to bother with all that, since InternetOpenUrl expects LPCTSTR (typedef as const TCHAR*) as its second argument. Try: [code] hFile = InternetOpenUrl( hINet, sUrl.c_str(), NULL, 0, 0, 0 ); [/code] | |
Re: Well, it seems likely the problem is in one of the two parameters you pass to the LoadBitmap function. You should check the return value of GetLastError after LoadBitmap fails, and look it up [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp]here[/url]. | |
Re: Do you mean the length of a c-style string (char array) or the length of a std::string? You could use strlen for the former, and the length() member function for the latter | |
Re: [code] string input; while (!ifile.eof()) { getline(ifile,input); cout << input << endl; } [COLOR=red] ifile.seekg(0,std::ios::beg); //reset read pos to beginning ifile.clear(); //clear eofbit [/COLOR] while (!ifile.eof()) { ifile.get(ch); cout << ch; } [/code] ![]() | |
Re: A major difference that hasn't been noted (unless I just missed it) is that 2005 uses C++/CLI for .NET programming, whereas 2003 uses the older managed extensions for C++. Just to clarify, C++/CLI is essentially its own language, though it is based on C++. Also, all the express versions are … | |
Re: [quote=~s.o.s~;333350]> In C. It's not a good idea to use that in C++, use cin.get() instead. Any good reason to back that up ? ;)[/quote] According to the standard, the c header files are deprecated, meaning they might be removed from the standard in future revisions. | |
Re: [code] Entry *entry; entry = [COLOR=#0000ff]new[/COLOR] Entry(media, entertainment); [/code] What are you trying to do here? You've already assigned the private members of the class (_media and _entertainment). And once the function returns, the newly allocated Entry object is lost (memory leak) | |
Re: In addition, you may want to search for "functor" or "function object" for more information. | |
Re: It's not an "abnormality," it's actually part of the C++ standard. As I understand it, operators like 'and' and 'or' are included for users with different character sets. See: [URL]http://david.tribble.com/text/cdiffs.htm#C99-alt-tok[/URL] Microsoft compilers appear to implement these as macros instead of keywords in the ciso646 header. As for the second part … | |
Re: Could you post a short program that demonstrates the problem (and that we can actually compile)? | |
Re: Since it appears you are using managed (.NET) code, why not use the .NET classes for file IO? I'm no expert at C++/CLI but it might be as simple as: [code] System::IO::StreamWriter^ sw = gcnew StreamWriter("file.txt"); sw->WriteLine(txt1->Text); [/code] | |
Re: The first part looks ok to me, but for the second part you also need to allocate space for each pointer in the array | |
Re: If you're going to use std::find like that, you need to define an equality operator for your info class: [code] class Info { public: bool operator==(const std::string& first_name); //... } [/code] However, you may want to use std::find_if instead. find_if allows you to specify an unary predicate as the matching … ![]() | |
Re: What do you expect to happen? After you increment 'p' in your third loop, it points past the last element of the array, so you're bound to get garbage data on your last outputs. | |
Re: Try indenting/using code tags (some IDEs can even indent for you!): [code] #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { // Declare Variables int withdraw; string name; double acctbalance, deposit; char choices; acctbalance = 0; //inputs, get the name and initial balance cout << "Enter Name: … | |
Re: hand appears to be a 2-dimensional array, in which case you need to compare each element (if you use only one subscript, you're comparing a pointer to an integer) [code] if (hand[i][0]==1 && hand[i][1]==2 && /*...*/) [/code] Of course, the problem here is that the cards may not be in … | |
Re: Is that table correct? I would think that you should start with two rabbits, then the number should double each month (i.e., exponential growth of 2^x) | |
Re: Any particulary reason you're writing procedural code in C++? A better approach would be to create a tree class that handles everything. Anyways, one major problem you have is that you pass a single pointer to traverse. The pointer in traverse is local to the function, so setting [inlinecode] current … | |
Re: Your code shouldn't even compile. You're missing a using declaration (I assume) and main should return 'int' Also, you should use std::stringstream instead of strstream (I believe the latter is deprecated) | |
Re: [quote=hoosier23;258055] What is the logic behind using float SavingsAccount::annualInterestRate = 0; right before my main? I see that you are setting annualInterestRate to zero, but why does this need to be done? Afterall, I have made annualInterestRate .03 in the default constructor. [/quote] I believe static variables will be automatically … | |
Re: Look at [URL="http://www.cplusplus.com/ref/iostream/ifstream/"]std::ifstream[/URL]. E.g.: [code] #include <fstream> #include <string> //... std::ifstream infile("somefile"); if (!infile.good()) { //failed to open } std::string line; std::getline(line,infile); //read a line into std::string [/code] | |
Re: Looks like a decent start. You just need to find a way to get the correct subscript into 'deck' to assign values in the inner loop, and then figure out how to shuffle the deck. The simplest way to do the last part is probably std::random_shuffle. You might also consider … ![]() | |
Re: How exactly are you linking this? I see you have two entry points (in pointTypeImp.cpp and circleTypeImp.cpp) and circleTypeImp.cpp relies on code from pointTypeImp.cpp. Obviously, though, you aren't linking these two files or you would have a multiple definition error for main. Generally, you should have separate files that contain … | |
Re: > One more thing, if i can't call main() recursively, can u suggest me any other way to call the main just after finish other function. You don't need to call main; when your function finishes, it returns the calling function. If you need the code to repeat, use a … | |
Re: Maybe there's a problem with your compiler/IDE installation or with the header files. Also, make sure your code is being compiled as C++ and not C | |
Re: How about reformmating that/adding code tags? | |
Re: Some more info can be found here: [URL]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_data_types.asp[/URL] Namely, it says that WINAPI and CALLBACK are both defined as __stdcall (it might not help you much, but [URL="http://msdn2.microsoft.com/en-us/library/984x0h58.aspx"]this[/URL] explains different MS specific calling conventions) | |
Re: Could you post a short example program that we can compile, and that demonstrates the problem? | |
Re: Try pressing alt-tab. It might appear elsewhere as well, but I can't think of where at the moment. | |
Re: > with a return 0 at the end of the program, as defined by the C++ Standard. Actually, return 0 is implicit for main() if a return statement is omitted. It's probably still good practice to explicitly return something, however. | |
Re: open expects a c-style string. You can use the c_str() std::string member function: [code] InObj.open(fname.c_str()); [/code] | |
Re: You might be able to use a pointer instead. E.g.: [code] [COLOR=#0000ff]#include[/COLOR][COLOR=#000000] <iostream>[/COLOR] [COLOR=#000000]const int ARRAY_SIZE = 5;[/COLOR] [COLOR=#0000ff]int[/COLOR][COLOR=#000000] array1[] = {1,2,3,4,5};[/COLOR] [COLOR=#0000ff]int[/COLOR][COLOR=#000000] array2[] = {6,7,8,9,10};[/COLOR] [COLOR=#0000ff]int[/COLOR][COLOR=#000000]* arrays[] = { array1, array2 };[/COLOR] [COLOR=#0000ff]int[/COLOR][COLOR=#000000] main()[/COLOR] { [COLOR=#0000ff]int[/COLOR] idx; std::cout<<"Enter index: "; std::cin>>idx; [COLOR=#0000ff]for[/COLOR] ([COLOR=#0000ff]int[/COLOR] i=0;i<ARRAY_SIZE;i++) std::cout<<arrays[idx][i]; } [/code] Note that … | |
Re: MailCarrier's default constructor tries to implicitly call the base class (Employee) constructor. You need to either define a constructor for Employee that takes no arguments, or explicitly call the constructor that you do have in MailCarrier's default constructor initializer list. | |
Re: 'person' is a map of maps, not a Person_class, so naturally it won't have those members. person["somestring"]["somestring"] would return (or set) a Person_class, however, so trying: [code] person[person.get_surname()][person.get_name()].begin() [/code] Wouldn't make sense (Person_class doesn't have a begin() method). I suppose you could do (untested): [code] for (i = person.begin(); i … | |
Re: Use the strstr function perhaps? I'm assuming you're using C, because you'd be better of using the std::string class and substr functions if you're using C++. | |
Re: What do you mean by "doesn't like it"? Could you post some example code? | |
Re: Have you actually looked through your code, line by line (possibly while debugging)? How about these lines, in the encryption function: [code] [COLOR=#008000]// put length back in the package [/COLOR] (*outbuf)[0] = newsize & 0xFF; (*outbuf)[1] = (newsize >> 8) & 0xFF; [/code] You seem to completely ignore that the … | |
Re: You probably either need to make the function non-static or the member data static. There is no way to access non-static data from a static member function without an instance of the class to operate on. | |
Re: [quote] * Turbo C++ -- very old 16 bit compiler. Works, but so does mouldy cheese. * Dev C++ -- up to date 32 bit compiler [/quote] Borland is actually bringing back their turbo products ([URL="http://www.borland.com/us/company/news/press_releases/2006/08_08_06_borlands_developer_tools_group_announes_plans.html"]link[/URL]), but for now I guess we can still scold people for using turbo And … | |
Re: [code] [LEFT]void ReadLine( char *line ) // line is a string { while ( (*line = getchar() ) != '\n' ) line++; *line = 0; } [/code] This is a buffer overflow waiting to happen. What happens if someone passes an array of some arbitrary size, say 50 bytes, and … | |
Re: you could try std::max_element in <algorithm> ![]() | |
Re: > BTW Im English I Dont Use Those Words For Those Sigh's In English Here. Really? What words do you use? I have never heard them referred to by any other name. > that takes time and money the ony thing i didnt understand was words... You do know how … | |
Re: Of course, if you're compiling with UNICODE defined, you'll have problems. You could probably do something like: [code] [COLOR=#0000ff]namespace[/COLOR][COLOR=#000000] MyProg[/COLOR] { [COLOR=#0000ff]typedef[/COLOR] std::basic_string<TCHAR> string; } //... MyProg::string str(TEXT("Hello world")); [/code] This would compile with or without UNICODE defined. | |
Re: > as if the list needs initialization. I'd say that's dead on. If you use malloc the list's constructor isn't going to be called. Since this is C++ you should be using new/delete. You should also avoid using naked pointers most of the time, in favor of smart pointers like … | |
Re: Do you know how to write a function? Surely your book/tutorial/etc tells you how. If you can write a non-templated function (accepting integers as arguments, perhaps) it shouldn't be hard to make it templated. | |
Re: Look into boost filesystem perhaps? I think it would satisfy those requirements (besides the xml file) | |
Re: [code] double pay = static_cast<double>(emp.hoursWorked) * emp.hourlyRate + OVERTIME_RATE * emp.hourlyRate * static_cast<double>(emp.hoursWorked - 40); [/code] A couple of problems. First, you're paying the employee for 41 hours at the normal rate [I]plus[/I] their overtime pay. This equals 41*10 + 1.5*10*1 = 425. Secondly, what happens if the worker works … | |
Re: For your linker errors, you need to link with wininet.lib. Also, I don't think InternetReadFile null-terminates the data, so take that into account. |
The End.