1,174 Posted Topics
Re: If ScheduledIn will be of type char (i.e. char ScheduledIn) then you cannot use double quotation marks in the if expression, use ' ' instead ... [code] char ScheduledIn; ... ScheduledIn = toupper(SchecduledIn); if (ScheduledIn == 'Y' || ScheduledIn == 'N')) { }[/code] | |
Re: The client needs to specify how much data it sends, i.e. you have to use the value you get from fread(). The server must write only the amount it gets from recvfrom(). The return value of recvfrom() gives you that information. And last but not least, you must add error … | |
Re: You may get ideas by looking in here [url]http://blogs.msdn.com/texblog/archive/2007/04/05/linking-native-c-into-c-applications.aspx[/url] | |
Re: y is a single integer, so it cannot be passed to the functions as such. You need an array of integers holding the data you have read in. [code]int main() { enum { ARR_SIZE = 3 }; int y[ARR_SIZE] = {0}; // Array of ints, at max ARR_SIZE elements int … | |
Re: Below is one option, maybe that is what you are after [code] private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { Form2 ^form2 = gcnew Form2; form2->Show(); } [/code] | |
Re: obj must NOT be const because you intend to modify it, so use only plain gydytojas& obj i.e. [icode]friend fstream& operator>>(fstream& fs, gydytojas& obj)[/icode] | |
Re: If you are going to set the value of mAccountNumber inside BankAccount::getAccountNumber(), then the function must be [B]non-const[/B], i.e. you need to have it like: [code]size_t BankAccount::getAccountNumber () { // set the value here ... }[/code] | |
Re: BCB version 3 is ancient, really consider updating to much more recent version, a full version is available for free, see [url]http://cc.codegear.com/free/cppbuilder[/url] To convince you, given that ThreadFunct1 is a member function of the form class, the following code [icode]ThreadHandle[0] = CreateThread(NULL, 0, ThreadFunct1, this, 0, &ThreadId[0]);[/icode] should not even … | |
Re: >> Why does the DLL did not get other values of the array??? I do not understand that. You output to the very same memory address each calculation [icode]out[[B][COLOR="Red"]0[/COLOR][/B]]=m_A[n+1]; // out[0] output from "C" to PSIM[/icode] shouldn't you change that subscript to follow the for loop? So it would be … | |
Re: [code] ... // [B]MaritalType[/B] is undefined at this point void extern displayStatus (MaritalType GrossType); ... [COLOR="Red"]{);[/COLOR] // <-- remove that one int extern getGross (); [/code] | |
Re: Shouldn't you rather be calling the setType() through the DO pointer instead of BP (assuming that the Base class does not and is not intended to have a setType() method), i.e. DO->setType("hello"); should work. | |
Re: I think the original findHighest() code was working quite well, to get the actual highest score, simply use person[max].testScore once the index of the highest score is known (i.e. max in this case), so ... [code]int findHighest(studentType person[]) { // assume highest score is at index 0 int max = … | |
Re: If you need to copy a file, you can use System::IO::File::Copy() | |
Re: The #import directive with Dev C++ is not doing what you expect, practically it is the same as #pragma once i.e. related to include guards instead of type library imports. See e.g. [url]http://www.delorie.com/gnu/docs/gcc/cpp_54.html[/url] If you really want to tackle Office automation, you could switch from Dev C++ to a free … | |
Re: <<then the program will print to the result.txt A (last line ,transformed) The reason why this happens is that the push() uses everytime the same buffer (=record), so effectively the stack contains pointers to this single buffer, and what was last written to the buffer, gets printed to the file … | |
Re: [QUOTE=info04;603372]but what is wrong?[/QUOTE] You are [B]excluding [/B]the lower and upper bounds, so you could change to [icode]if ( i >= 65 && i <= 90 )[/icode] or [icode]if ( i > 64 && i < 91 )[/icode] The standard libraries provide functions for checking characters, see e.g. here [url]http://www.cplusplus.com/reference/clibrary/cctype/[/url] | |
Re: [QUOTE=still_learning;601416] So for instance, if I have vector<int> vecList; as my vector and I want to replace vecList[5] with an integer entered by a user, how exactly can I do that? [/QUOTE] Simply by [icode]vecList[5] = int_from_user;[/icode] To lookup a value to change, you can use std::find() [code]#include <algorithm> ... … | |
Re: Anyone interested in programs written in similar fashion can take look at here [url]http://www2.de.ioccc.org/years.html#2004[/url] | |
Re: [QUOTE=nelledawg;601099]When I select 5 to quit and it asks if I'm sure, if I type "Y" it breaks and I get a window that says "Unhandled exception at 0x1029984f (msvcr90d.dll) in lab 10 FIX.exe: 0xC0000005: Access violation reading location 0x0000000a. [/QUOTE] Change your message() function to following [code]void message(char *msg) … | |
Re: You are missing [icode]using namespace System::Collections::Generic;[/icode] | |
Re: [QUOTE=vedmack;600835]any ideas?[/QUOTE] This is bit vague but an idea anyhow, so here goes ... Use EnumProcesses() to map process ids to executable names, that gives you the process id of the target program. Then use EnumWindows() together with GetWindowThreadProcessId() to figure out the window handle you need to operate on. … | |
Re: [CODE] struct gydytojas { <snip> friend ostream& operator<<(ostream& os, const gydytojas& obj) { // In this function you have to write the data you want // in to the ostream os. // for example, write the integer values os << obj.gydid << obj.amzius << obj.specialyb << obj.telefonas << obj.asmkod; // … | |
Re: I think you should forget trying to use a String to store and restore a color. Instead, you can simply use a member variable of type System::Drawing::Color to save the original color and restore it back when necessary. So in your Form class, add a member variable like; [icode]System::Drawing::Color ColorSaved;[/icode] … | |
Re: I suggest that you familiarize yourself with the concept of passing by reference, including passing by const reference. And while you are at it, check out returning by reference too. Now you are passing vectors by value into functions that are supposed to modify the input, however, that simply will … | |
Re: [QUOTE=blah70;599158]Can anyone help me please[/QUOTE] Try proceeding with posting e.g. the code you have written, an explanation of what is failing with it/what you perhaps don't understand, what the program should accomplish and so on. | |
Re: [QUOTE]So it seems that the decimals is dissapearing in the conversion. [/QUOTE] atoi() converts a character string to an [B]integer[/B] meaning that no decimal points are available. The stringstream is capable of doing the conversion, so you don't need to use any of the C-library conversion routines. [code] std::string Number3 … | |
Re: [QUOTE=marco93;598704]codeproject has nothing else than copies of MSDN samples.[/QUOTE] That just isn't quite true, you can convince yourself by taking a look, for example, in here [url]http://www.codeproject.com/KB/MFC/UltimateToolbox.aspx[/url] | |
Re: Just a suggestion, have you considered using a struct/class the encapsulates the data of a single item? You could then operate with a vector of such struct/class instead of the many separate vectors you have now. E.g. [code]struct Item { string ID; string Name; double Price; }; void getData(ifstream& infile, … | |
Re: Below is an arbitrary example, hope it gives some insight [code]#include <fstream> #include <string> using namespace std; class MyClass { string strings[2]; int value; friend ostream & operator << (ostream & stream, const MyClass & obj); public: MyClass(const string & s1, const string & s2, const int n) { strings[0] … | |
Re: Here is a thread about the books [url]http://www.daniweb.com/forums/thread70096.html[/url] | |
Re: [quote]An example is BestScanPositions.at(0) is 0 and BestScanPositions.at(1) is also 0. Then BestCols.at(0) is 19 and BestCols.at(1) is 16!!! Weird, eh?[/quote] Just guessing .. could it be that you actually do the 'offending' loop twice or more without clearing the vectors' content in between? | |
Re: vardas is an array of 25 Strings. So if you want to keep it that way, you need to use something like: [icode]gydmas[1].vardas[[B]some_valid_index_here[/B]] = Edit21->Text;[/ICODE] | |
Re: Sure you can write your C++ code using notepad, it's a text editor after all. But you need to have a compiler/linker to turn the code into a program which you can then run. | |
Re: [QUOTE=jimJohnson;596954]the sort from smallest to largest[/QUOTE] See the comment below ... [code]int main() { int count; numbers_used = 0, <snip> // You are passing numbers_used, which is zero, // shouldn't you be using [B]count[/B] instead here? Sort(Size, numbers_used); } [/code] What do you mean by "setting up my widths" ? | |
Re: In [url]http://www.sqlapi.com/OnLineDoc/index.html[/url] it says that for Borland, the following libraries are available to choose from sqlapib.lib - for linking with release version of dynamic library (Borland C++) sqlapibd.lib - for linking with debug version of dynamic library (Borland C++) sqlapibs.lib - for linking with release version of static library (Borland … | |
Re: [QUOTE=e_pech;597033]I'm new to C++ with MFC..[/QUOTE] You probably will find the CString class useful. See e.g. the CString::Format() function. | |
Re: [QUOTE=Lass;597104]how could i arrange the output?[/QUOTE] Use double quotation marks " " instead of ' ', for example; [code] ofile<<patient.name<<[B]" "[/B]<<patient.age<< [B]" "[/B] <<patient.gender<< [B]" "[/B] <<patient.fileNumber<< [B]" "[/B] <<patient.illness<< [B]" "[/B] <<patient.degree; [/code] You can choose the length of the string as you wish. >> but what if i … | |
Re: I'm trying to point out the errors in your code, so here we go .. [CODE] #include<iostream> using namespace std; int main() { int value,check=1; cout<<"Enter a number: "; cin>>value; while(value>=0) { int newvalue; cout<<"Enter another value: "; cin>>newvalue; if(value>newvalue) cout<<" is increasing"; check=0; [B]// you are not using braces … | |
Re: [QUOTE=rem0404;595860]when i run the program and try to add a song, the addsong function always tells me that the item already exists.[/QUOTE] That happens because the logic in [icode]if (titles[i].compare(t_title) && artists[i].compare(a_artist))[/icode] is wrong. std::string::compare() returns zero if the items are EQUAL, so you need to rewrite that comparison. See … | |
Re: Consider the following [code] // A variable of class cdrom on the stack cdrom cdrom1; // invoke the loadinfo() member function cdrom1.loadinfo(); // Allocate a variable of class cdrom on the heap cdrom * cdrom_ptr = new cdrom; // invoke the loadinfo() member function cdrom_ptr->loadinfo(); [/code] | |
Re: You need to randomize the hillsize and gridref values within the loop in which you initialize the list. | |
Re: >> i defined it in 2 header files but if i take it out from one then it will say S is undefined Define it only once, and use #include "where_S_is_defined.h" where needed (i.e. where you get the 'undefined' error) | |
Re: There is a mismatch with the Fill_Array() function, prototype is [code]void Fill_Array(int Size[], int& count);[/code] whereas the implementation is [code]void Fill_Array(int Size[], int& count, [B]int& number_used[/B])[/code] In main(), you are using it in the manner which implies that you should remove the 'int& number_used' argument from the implementation. | |
Re: STL's sort() briefly introduced here ... [url]http://en.wikipedia.org/wiki/Sort_(C%2B%2B[/url]) | |
Re: You could turn Ancient Dragon's code into a function and then use it to process your input file line-by-line. It could look something like (the function is here AD()) [code] void AD(char * record, char * record_out) { char *p1 = record; char *p2 = record_out; // Rest of the … | |
Re: [QUOTE=Black Magic;594042]i still get: invalid suffix expected ; before int[/QUOTE] Then you most probably still use there a variable whose name starts with a digit, so please double-check the code. | |
Re: Here is one (sort of) short article discussing floating point comparisons [url]http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm[/url] | |
Re: [QUOTE=David Wang;593702]The red parts are my changes. The last line used to be "this->label2->Text = L"label2";" , showing "label2" in Form2. But my change is not working and got error. I wonder how to fix it. [/QUOTE] What is the error(s) you are getting? Might be helpful to post the … | |
Re: [QUOTE=NinjaLink;593674]Can I get an example of it. Do you mean the "&" sign?[/QUOTE] One example is sumGrades(), inside that function you modify fcounter, mcounter, msum and fsum. However, none of these are passed in by reference (&) so the sumGrades' code does not have the intended impact. So you should … | |
Re: You are doing integer math, change to floating point instead (i.e. from int to double or float). |
The End.