1,174 Posted Topics

Member Avatar for amitahlawat20

[code]int put_element(int i, int j) { // check here that both i and j are within the bounds // you currently have allocated ... // And remember that indexes are zero-based, i.e. // if you have 'int arr[2]', the last valid index is 1 (not 2) return p[i][j]; }[/code]

Member Avatar for mitrmkar
0
99
Member Avatar for Gerritt

In your show_costs() function ... [code] int scrub; if(n[[COLOR="Green"]some_valid_subscript_here[/COLOR]] < 5) { // what is the value of [B][COLOR="Red"]scrub[/COLOR][/B] here? // and where does it come from?? n[scrub] == c; scrub++; } [/code]

Member Avatar for mitrmkar
0
200
Member Avatar for trick

Try the following ... <a href="file:///c:/test.csv">open test.csv</a> should work if you have the file c:\test.csv on disk.

Member Avatar for peterpollen
0
144
Member Avatar for curt1203

Maybe you could use strtod() as a 'workhorse' and switch to using a double instead of integer. See [url]http://www.cplusplus.com/reference/clibrary/cstdlib/strtod.html[/url] For example, [code] char myStr[30] = ""; while(1) { cout << "Enter a decimal number: (q to quit)" << endl; cin.getline(myStr, 30); if('q' == *myStr) { break; } char * endptr …

Member Avatar for curt1203
0
115
Member Avatar for Queen of Dreams

An introduction to classes can be found e.g. here [url]http://www.cplusplus.com/doc/tutorial/classes.html[/url] [QUOTE=Queen of Dreams;555770] how to write answer with CLASS... [/QUOTE] To output something to screen, even from within your class, you can use cout. An example: [code] #include <iostream> using namespace std; int main() { int value = 123; cout …

Member Avatar for mitrmkar
-1
226
Member Avatar for Crushyerbones

The following can also be done .. it does not involve strcpy() or arrays, instead it uses a single pointer (real_out_ptr) [code] char const * real_out_ptr = "This REALLY shouldn't have happened.\n"; int output_type = 1; if (output_type == 1) real_out_ptr= "binary"; else if (output_type == 2) real_out_ptr = "octal"; …

Member Avatar for Crushyerbones
0
113
Member Avatar for adnanius

Seems that operator << is unable to take a 'photon' as input. You probably need to write something like: [code]std::ostream & operator << (std::ostream& s, const photon & p) { // stuff the content of the photon into the stream ... // s << p.abc << etc ... return s; …

Member Avatar for adnanius
0
704
Member Avatar for ITbull

Change swap([B][COLOR="Red"]&[/COLOR][/B]string_array[i], [B][COLOR="Red"]&[/COLOR][/B]string_array[i-1]); to swap(string_array[i], string_array[i-1]); because swap() expects two pieces of 'char*', not 'char **'.

Member Avatar for mitrmkar
0
137
Member Avatar for lifei

If you will not be using MFC (for any reason), check out ZedGraph [url]http://sourceforge.net/projects/zedgraph/[/url]

Member Avatar for Ancient Dragon
0
171
Member Avatar for purepecha

Call [code]swapArgs(&parmA,&parmB);[/code] again after [code]printf("Swapped values A=%d, B=%d.\n",parmA,parmB);[/code]

Member Avatar for mitrmkar
0
72
Member Avatar for midimatt

p.level is an integer, hence %d instead of %s ... [code]int viewcharacter() { printf("Name:\t%s\n", p.name); printf("Level:\t%[B][COLOR="Red"]d[/COLOR][/B]\n",p.level); }[/code]

Member Avatar for midimatt
0
153
Member Avatar for Jennifer84

Use substr(), to extract '1234', you could do: [code=cplusplus] const std::string Value10 = "Number(1234)"; const size_t start = Value10.find("("); const size_t end = Value10.find(")"); const std::string extracted = Value10.substr(start + 1, end - start - 1); cout << "extracted: " << extracted.c_str() << endl; [/code] In same, fashion you can …

Member Avatar for mitrmkar
0
94
Member Avatar for agrawalashishku

A couple of things, 1) you are using bitwise OR operator in [code]if((current[level-1]==n)[B][COLOR="Red"]|[/COLOR][/B](current[level+1]==n)) return false;[/code] You probably meant logical OR i.e. [code]if((current[level-1]==n)[B][COLOR="Red"]||[/COLOR][/B](current[level+1]==n)) return false;[/code] 2) and then usage of 'goto', you could throw away the 'mainloop' label and inside the for() loop replace goto mainloop; with break; and just delete …

Member Avatar for agrawalashishku
0
97
Member Avatar for risa

What do you mean by 'crashing'? Is it so that VirtualAlloc returns NULL and you are still using the pBuffer? Or something else?

Member Avatar for risa
0
785
Member Avatar for Jennifer84

This is practially pretty much what Lerner said ... [code] std::string Value = "a,b,c,d,e,f"; istringstream is(Value); std::string s; std::vector<string> v; while (getline(is, s, ',')) { // add item v.push_back(s); } // iterate through the vector and output each item ... for(std::vector<string>::iterator it = v.begin(); it != v.end(); it ++) { …

Member Avatar for Jennifer84
0
190
Member Avatar for winky

You'd probably want to use a loop for operating with user input, i.e. something like [code] // use an instance of btree class ... btree tree; // a Node pointer Node * nodeptr = NULL; do { cout << "Please enter a menu choice:\n" << "'A' - In-order Print\n" << …

Member Avatar for mitrmkar
0
124
Member Avatar for mazoo

If you open a command prompt (cmd.exe) and type in e.g. gcc --version what happens?

Member Avatar for VernonDozier
0
119
Member Avatar for Jboy05

[code] int Func3 () { int Option; int A = 2; int B = 3; double C = 2.5; double D = 3.5; cout << " Enter your select: "; cin >> Option; if(1 == Option) { // Call func1() here } else if(2 == Option) { // Call func2() …

Member Avatar for mitrmkar
0
129
Member Avatar for Jennifer84

Something like this ... [code]MessageBox::Show(this, "OK to proceed?", "A caption here ...", MessageBoxButtons::OKCancel, MessageBoxIcon::Question);[/code]

Member Avatar for Jennifer84
0
3K
Member Avatar for cosmos22

Your main() is not returning an int, maybe nothing at all or something else, so .. [code]int main(int argc, char * argv[]) { // your code here // return some integer value, in this case zero ... return 0; }[/code]

Member Avatar for mitrmkar
0
184
Member Avatar for IAmPat

First things first, I second to WaltP, really format your code to make it readable. Now it's close to unreadable. Arrays are zero-indexed .. hence both of your string arrays now have an unused index 0, in other words, you should do with smaller (by one) string arrays. [code]string squares[] …

Member Avatar for mitrmkar
0
159
Member Avatar for larry12720

Also the second operand really must be changed from while(strcmp(pt->next, [B][COLOR="Red"]' '[/COLOR][/B])!=0) to while(strcmp(pt->next, [B][COLOR="Red"]" "[/COLOR][/B])!=0) because C-compiler treats ' ' as an integer and strcmp() does not expect an integer.

Member Avatar for abhikkumarbasu
0
137
Member Avatar for trick

Just to give some basic ideas, you might do with the following simple setup, without linked lists involved at all. Use a structure like e.g. [code]typedef struct { const char * _pWord; // pointer to the word unsigned int _nFreq; // its frequency }Entry;[/code] To make it easy, have a …

Member Avatar for trick
0
607
Member Avatar for austinslik

Since I don't know what the function is supposed to do, I cannot offer much advise. However, if you plan to change the values of the parameters passed into the function, you need to pass the parameters by reference, instead of by value. I.e. public char CheckDir(int [B]&[/B] row, int …

Member Avatar for austinslik
0
135
Member Avatar for jimJohnson

Remove the [code]int Get_Number (int x);[/code] that is there on line 22.

Member Avatar for VernonDozier
0
87
Member Avatar for SofMy

>> you can edit your first post. It seems that once posted, a post remains editable for some short period of time and then enters a non-editable mode. Is there any way, for one to edit one's own post regardless of how long it has been on the forum? By …

Member Avatar for mitrmkar
0
126
Member Avatar for daviddoria

Try following [CODE] [B]// Point.h[/B] class Vector; class Point { public: Vector GetVector(); }; ////////////////////////////////////////// [B]// Point.cpp[/B] #include "point.h" #include "vector.h" Vector Point::GetVector() { Vector v; return v; } ////////////////////////////////////////// [B]// Program.cpp[/B] #include <iostream> #include "Point.h" #include "Vector.h" using namespace std; int main() { Point P; Vector V; return 0; …

Member Avatar for mitrmkar
0
110
Member Avatar for nelledawg

Fix the flawed scanf_s() call to be like below: [code]double getdouble(char item[], double min) { ... printf("\nEnter a ticket %s greater than or equal to %d: ", item, min); scanf_s("%[B][COLOR="Red"]lf[/COLOR][/B]%*c", &ticketquan); ... [/code] Some calls to printf() are erroneous in the same way, i.e. you use %d to output a …

Member Avatar for mitrmkar
0
161
Member Avatar for jer_stud56

>> Now I have another problem... I suspect that your code goes something like this; [code][B]{[/B] // <- start of a block (for some reason) ofstream fout; ... code ... [B]}[/B] // <- end of the block ('fout' does not exist anymore at this point) ... code ... // Report …

Member Avatar for mitrmkar
0
602
Member Avatar for atish00

You can use following: [code]char *p = "Hello World"; char c = *(p + 1); // 'e' [/code]

Member Avatar for Dave Sinkula
0
139
Member Avatar for fiz hafiz

fscanf() was missing one argument. [CODE] int main() { int i=0; [B][COLOR="Red"]int d=0;[/COLOR][/B] FILE *all; all = fopen(FILENAME1, "r"); while(fscanf(all,"%d", [B][COLOR="Red"]&d[/COLOR][/B])!=EOF) ... }[/CODE]

Member Avatar for mitrmkar
0
52
Member Avatar for Jboy05

>> function named MPG which [B]returns[/B] the number of miles a car can travel with one gallon of gasoline MPG() simply cannot be void, because it has to return the requested value.

Member Avatar for superjacent
0
181
Member Avatar for demroth

You have to change the initialization of [B]numbers[/B] [code] long count = 0; //counts the number of numbers in the input file long items = 0; long numbers[count];[/code]

Member Avatar for demroth
0
160
Member Avatar for Jennifer84

Could it be that comboBox2->SelectedItem is a NULL reference? Calling Box1->push_back() like you do is OK.

Member Avatar for Jennifer84
0
173
Member Avatar for Dr_Pepper

After a ver quick look into the code, at least insideTriangle() uses uninitialized variables. [CODE] insideTriangle (double base, double height, double p_x, double p_y, double p_find_x, double p_find_y) { double aX, bX, cY, centerY; aX = base - p_x; centerY = [B][COLOR="Red"]cY[/COLOR][/B] - height; if (p_find_x <= [B][COLOR="Red"]bX[/COLOR][/B] && p_find_x …

Member Avatar for hammerhead
-1
525
Member Avatar for rohoni

At the end of the program, try getting the length of the 'name' using strlen() i.e. [code] ... printf("%c",name[i]); printf("\nlength of name is: %d", strlen(name)); }[/code]

Member Avatar for gerard4143
0
97
Member Avatar for bleonard989

It is faster/easier to locate the error spots in the code if you post the compiler errors too.

Member Avatar for mitrmkar
0
527
Member Avatar for kylcrow

[QUOTE=kylcrow;545269]Google does not help me, because all I can find is how to do this with a struct, not a class.[/QUOTE] The difference between a class and a struct is that, with a class everything is private by default, whereas with a struct everything is public by default. So you …

Member Avatar for Ancient Dragon
0
317
Member Avatar for cosmos22

What is the symptom of it 'not working' ? (Please be more precise about failures when you post).

Member Avatar for Ancient Dragon
0
213
Member Avatar for rwagnes

Here is a quite good explanation for sheets/pages: [url]http://support.microsoft.com/kb/300606[/url]

Member Avatar for mitrmkar
0
1K
Member Avatar for plgriffith

Remove the & operator, tempString as such must be used in that scanf (tempString is a pointer, hence no need for &). [code]scanf("%s", [B][COLOR="Red"]&[/COLOR][/B]tempString);[/code] Then allocate memory [B]before[/B] copying. [code]temp->artist = (char*) malloc(strlen(tempString)+1); strcpy(temp->artist, tempString);[/code] You may want to check that malloc() actually succeeded, (i.e NULL != temp->artist). Also remember …

Member Avatar for plgriffith
0
2K
Member Avatar for rohoni

[code]const char const * strings[] = {"abcdeedcba\n","abcdxxdcba\n","abcxxxxcba\n","abxxxxxxba\n","axxxxxxxxa\n", NULL}; for(char const ** ptr = strings; *ptr; ++ptr) { printf(*ptr); } [/code]

Member Avatar for WaltP
0
128
Member Avatar for sgw

Please post the error message exactly as it is displayed. The computer probably lacks one or more .dlls that your program needs.

Member Avatar for mitrmkar
0
111
Member Avatar for prushik

Post the code that shows how you have initialized the user struct + buffer and what are the crazy values?

Member Avatar for mitrmkar
0
157
Member Avatar for prushik

Try seeing which error code WSAGetLastError() returns, error codes are listed in [url]http://msdn2.microsoft.com/en-us/library/ms740668(VS.85).aspx[/url]

Member Avatar for prushik
0
51
Member Avatar for Jennifer84
Member Avatar for Jennifer84
0
133
Member Avatar for onemanclapping

atum.cpp is a source file, not an executable file. You should locate the program you have compiled i.e. the executable file.

Member Avatar for onemanclapping
0
215
Member Avatar for dkwantee

Look at the for loop's condition for(i=0;[B][COLOR="Red"]i<4[/COLOR][/B];i++) i.e. "i" is not less than four at that line.

Member Avatar for mitrmkar
0
254
Member Avatar for Jennifer84

If you need to "find the Last "/" in the string" try using the std::string::find_last_of() to get index of the last slash in a string. For details see e.g. here [url]http://www.cplusplus.com/reference/string/string/find_last_of.html[/url]

Member Avatar for Jennifer84
0
85
Member Avatar for alone2005

[QUOTE] what this function mean [code] operator T*() {return data_;} [/code][/QUOTE] It returns a pointer to the member variable data_ of the array class.

Member Avatar for farag
0
189

The End.