1,118 Posted Topics

Member Avatar for Etniespr101

You need to consider the format of your input. I will presume something like [code] Avery Brown 129 Landis St. Chapel Hill, NC 01234 555-1234 Emma Green 13 Rabbit Run Rd. Chapel Hill, NC 01234 555-2933 [/code] Every four lines is a different record. So read one whole record at …

Member Avatar for zandiago
0
111
Member Avatar for dasani

Close. Remember, 6 doesn't evenly divide 100: [inlinecode]if (((num - 100) % 6) == 0) cout << endl;[/inlinecode] Hope this helps.

Member Avatar for dasani
0
100
Member Avatar for sgk26p10p07

SGDT is [B]0F 01 /0[/B]. SIDT is [B]0F 01 /1[/B] LGDT is [B]0F 01 /2[/B] LIDT is [B]0F 01 /3[/B] The /0, etc. refers to the R/M field of the ModR/M byte of the opcode. So SGDT would be coded as [B]0F 01 00[/B] followed by three or four bytes …

Member Avatar for sgk26p10p07
0
896
Member Avatar for n.aggel

Google "socket programming in c" Does it have to be in C? Python makes sockets trivial, whereas in C it is a messy pain. Good luck.

Member Avatar for stupido
0
191
Member Avatar for hellokitty88

Use [B][[i][/i]code[i][/i]][/B] tags please. First, watch your syntax. Any time you have a [color=red][B];[/B][/color] you are terminating a statement. So [inlinecode]Animal *M;= new Animal();[/inlinecode] is two separate statements: [inlinecode]Animal *M;[/inlinecode] and [inlinecode]= new Animal();[/inlinecode]. The first 'redeclares' the variable [B]M[/B]. The second is error. What you want to say is …

Member Avatar for Duoas
0
96
Member Avatar for mank

In C, an array variable is a pointer to the first element of the array. Hence, you can treat the variable as any other, keeping in mind that manipulating the array variable is different than manipulating the array elements. [code=C] float *reverse_it( float *a, int len ) { float x, …

Member Avatar for mank
1
2K
Member Avatar for catdieselpow

I'm always just a little taken aback by things like [inlinecode]getch();[/inlinecode] and [inlinecode]system( "pause" );[/inlinecode] stuck in people's code. It is non-portable and in the case of [B]getch()[/B] and [B]cin.get()[/B], leaves the input in an indeterminate state. Since the standard input is line bufferered, the most robust code would be …

Member Avatar for WaltP
0
209
Member Avatar for Brent720

It is unfortunate, but I don't think the Delphi tRichEdit class can do unicode. The [B]lines[/B] member is a [B]tStrings[/B] object, which uses the [B]string[/B] type instead of [B]wideString[/B]. I use Delphi 5.0 and I've been playing around with the rich edit control myself for the past week or so... …

Member Avatar for Duoas
0
458
Member Avatar for sgk26p10p07
Re: Vesa

You need to find yourself a good reference. I recommend Ferraro's [B]Programmer's Guide to the EGA and VGA Cards[/B]. It's a bit out of date but all the info you need is there. To set a bank use something like: [code] mov ax, 4F05 ; VESA function: mov bh, 0 …

Member Avatar for Duoas
0
209
Member Avatar for cwtliew

You haven't used [[B][/B]code[B][/B]] tags so I can't tell exactly what you were thinking when you wrote this, but your problem is with your [B]for[/B] loops and indentation. Whenever you make something, always indent to show [I]yourself[/I] which statements belong to another statement. If more than one statement is indented …

Member Avatar for cwtliew
0
95
Member Avatar for the.alchemist

One of the lovely things about C... Check line 5 of [B]changeSetting()[/B]: you've got the [b][color=red];[/color][/b] on the wrong side of the [b][color=red]}[/color][/b]. Every single statement in C must be terminated by a semi-colon. It's the little things that get you...

Member Avatar for Salem
1
116
Member Avatar for adrive

Before go off trying to implement your own RTF parser you might want to tell us what exactly you want to do. Are you trying to simply display a form with a bulleted list? Are you trying to create a document to save to disk? Are you trying to embed …

Member Avatar for adrive
0
387
Member Avatar for hectic

Your syntax needs help. See the [URL="http://www.parashift.com/c++-faq-lite/templates.html"]C++ FAQ Lite[/URL]. The difference between a regular class or function and a template class or function is just that you have [inlinecode]template<typename Foo>[/inlinecode] in front of it, and can use [B]Foo[/B] as a generic type instead of a specific type like [B]int[/B], or …

Member Avatar for hectic
0
422
Member Avatar for Duki

That's because you've got it buried in the [B]Employees[/B] namespace. Use its full name: [inlinecode]Employees::TitledEmployee frank;[/inlinecode] Have fun.

Member Avatar for Duki
0
91
Member Avatar for theteamdrunk

A linked list node always looks like this: [code=C] typedef struct tag_node { int value; struct tag_node *next; } node_t; [/code] The value itself may be any type of thing, even though in this example I used an [B]int[/B]. Also, you could have more than one value in each node. …

Member Avatar for Duoas
0
102
Member Avatar for DREAMER546

Both should work. Personally, I prefer to use lots of parentheses to make it obvious (both to myself and to the compiler) what exactly I mean to say: [code=C++] cout << ( (grade == 'A') ? "excellent" : ( (grade == 'B') ? "very good" : ( (grade == 'c') …

Member Avatar for DREAMER546
0
120
Member Avatar for Phanta

It looks to me like you are mixing too many types. To read a row of characters just read in a [B]string[/B] [code=Delphi] var s: string; begin writeln( 'Please enter a sentence:' ); readln( s ); ... [/code] The [B]words[/B] function should take some arguments instead of using globals: [code=Delphi] …

Member Avatar for Duoas
0
163
Member Avatar for tnvkrishna

The code [inlinecode]-a[/inlinecode] is a unary operator, so he isn't trying to do anything weird. The argument to your operator function should be a reference: [inlinecode]zz operator - ( zz &z )[/inlinecode] Otherwise it looks fine.

Member Avatar for Duoas
0
152
Member Avatar for parthiban

An array is just an ordered list of things. So for the array to be serializable the elements of the array must be serializable. Hence, your conclusions 1 is correct. Conclusion 2 is correct for all elements in an array (not just objects). However, conclusion 3 needs a little help: …

Member Avatar for parthiban
0
103
Member Avatar for Barefootsanders

You typed "port()" but I think you meant [B]fork()[/B]. That's an OS-specific call. On Windows you have to use [B]CreateProcess()[/B]. If you are just doing homework at home, you can ssh into your school and do it over the internet, or you can download [B]Cygwin[/B] or [B]MSys[/B] to compile it …

Member Avatar for Duoas
0
316
Member Avatar for theteamdrunk

There's no reason you can't separate them. [code=C] int i; double d; char c; printf( "Please enter a number\n" ); getline( message ); d = atof( message ); printf( "Please enter an integer\n" ); getline( message ); i = atoi( message ); printf( "Please enter a character\n" ); getline( message …

Member Avatar for Duoas
0
122
Member Avatar for phalaris_trip

Yeah, listen to [B]Ancient Dragon[/B]. Sounds to me like you've got yet another bad instructor. The guy needs to go read his own textbook. Follow [B]AD[/B]'s code, but if you want to have different initializers for each object, use an array: [code=C++] int main( int argc, char *argv[] ) { …

Member Avatar for Duoas
0
2K
Member Avatar for DemonSpeeding

The [B]switch[/B] statement itself has an expression unconditionally modifying image[k][m], so you will have to add an [B]if[/B] statement before the switch: [code=C] if (image[k][m] != 0) switch (image[k][m] = ...) { ... } else cout << " "; [/code] You also need to watch your indentation. The [inlinecode]cout << …

Member Avatar for Duoas
0
148
Member Avatar for Sofo

The best way to terminate an application is to call [inlinecode]application.terminate[/inlinecode] This prevents a lot of problems and can be called anywhere. Avoid using [B]tTimer[/B] as much as possible because it is a "heavy" object --chewing up resources and time. Hope this helps.

Member Avatar for Duoas
0
166
Member Avatar for jigart4586

Best answer is, [color=red][B]don't do that.[/B][/color] You are playing with [I]undefined behavior[/I]. For any single variable, there should be a [I]maximum[/I] of [I]one[/I] pre/post increment/decrement operator. Otherwise your results may vary: You could just as easily have gotten 1 2 3, 1 3 2, 3 1 2, 2 1 3, …

Member Avatar for Ancient Dragon
0
110
Member Avatar for esquared

Make sure you are using a good reference when you use interrupts. Also, try to reduce the number of instructions you use. [code] ;set the video mode to CGA 80 x 25, 16-color mov ax, 0300h int 10h ;wait for a keypress mov ah, 1 int 21h ;clear the screen …

Member Avatar for Duoas
0
171
Member Avatar for warpstar

Pointer syntax in C/C++ is very flexible, but likewise very confusing. You can say something like [inlinecode]int i, *pi, **ppi;[/inlinecode] but this should be read carefully as [inlinecode]int i; int* pi; int** ppi;[/inlinecode] :an integer, a pointer to an integer, and a pointer to a pointer to an integer. Yeah, …

Member Avatar for Duoas
0
99
Member Avatar for SHWOO

[B]part one[/B] Don't load "asteroid.bmp" from file every time you call [B]DrawBitmap()[/B]. That's a huge slowdown. Load the bitmap first, (say in [B]Game_Init()[/B]) and have [B]DrawBitmap()[/B] take a handle to the bitmap to draw instead of a filename. Don't forget to use [B]DeleteObject()[/B] before terminating to get rid of the …

Member Avatar for Duoas
0
239
Member Avatar for akame

Since no one else has answered this... I am not familiar with using MatLab. (I presume you mean MatLab.) However, you should be aware that affine transformations are matrix multiplications applied to an affine space --that is, applied to vectors. A vector can be any dimension you want. Your transformation …

Member Avatar for Duoas
0
95
Member Avatar for cl3m0ns

Your []'s are in the wrong spot. Say [code] DisplayArrays( studentNames, scores ); [/code] and [code] double DisplayArrays( string studentName[], int score[] ) [/code] Hope this helps.

Member Avatar for WaltP
0
162
Member Avatar for Annex

You have some serious syntax errors going there. This is my best guess as to what you mean: [code=Delphi] function Rus( mes: string ): string; var i: integer; // number of processed character begin for i := 1 to length( mes ) do case mes[i] of 'A'..'Z', 'a'..'n': mes[i] := …

Member Avatar for Annex
0
71
Member Avatar for clski1973

It is good that you are thinking in terms of separating out functions in your code. In this case, there is no compelling reason to do it either way. Each loop must iterate through the exact same sequence of numbers. If you were to use two separate loops though, you …

Member Avatar for WaltP
0
145
Member Avatar for santhiks

"Graphics" is a [B][I]huge[/I][/B] category. What kind of graphics do you want to do? Windows and buttons and scrollbars? 2D picture processing? 3D animations? Video games? ASCII art? I ask because C++ doesn't do graphics. C++ can use libraries that do graphics. Depending on what you want to do we …

Member Avatar for Xavier2k
0
79
Member Avatar for rickshaw

You'll have to enable command extensions and use the [B]for[/B] command. Works on XP. [code] :: change to the proper directory (probably C:\Documents and Settings\) %SystemDrive% cd "%ALLUSERSPROFILE%\.." :: for each subdirectory name except "Administrator" and "All Users" do delete it for /D %%dir in (*) do ( if not …

Member Avatar for Duoas
0
101
Member Avatar for warpstar

[quote="Ancient Dragon"] >>And whats the difference in malloc and calloc? calloc() calls malloc() then initializes the data to all 0s. [/quote] Please read answers given to you. And don't quote yourself... A computer program is loaded into several parts of memory. There is the code (functions and the like), data …

Member Avatar for Salem
0
221
Member Avatar for jaepi

There isn't one. GetDiskFreeSpace() is an OS-specific function. If you are looking to find free disk space in linux, google [B]statfs()[/B]. That's not a standard function anywhere, but it is a common extension to System V. It obsoletes [B]ustat()[/B], which also does the job. Hope this helps.

Member Avatar for jaepi
0
236
Member Avatar for jonbuckets

This is actually one of the most insidious problems people learning C/C++ get. The problem is one of [B][I]type[/I][/B]. 1/2 is integer 1/2.0 is floating point So, for example, when you go to calculate the PDF you say [inlinecode]pdf=((1/2)+INV_SQRT_2PI * ...[/inlinecode] That one-half there is an [B][I]integer[/I][/B] expression, which gets …

Member Avatar for jonbuckets
0
96
Member Avatar for still_learning

It looks like you are playing with [B]template classes[/B]. You might want to read up on templates over at [url]http://www.parashift.com/c++-faq-lite/[/url] The first problem is that there is a variable or class or function named [B]first[/B] being used somewhere in the code (lines 43, 74, 116) that either doesn't exist or …

Member Avatar for Duoas
0
223
Member Avatar for rohit83.ken

I haven't messed with VC++ for a long time, but I believe it comes with some form of [B]make[/B]. Open a command window and make sure the VC++ bin directory is in the path (the directory that has all of VC++'s exe files), and type [inlinecode]make[/inlinecode] as usual. MS and …

Member Avatar for Ancient Dragon
0
105
Member Avatar for RohitSahni

Write the values to a file from your program. [code=C++] ofstream outs( "data.txt" ); outs << value1 << "\n" << value2 << std::endl; [/code] Choice of shell matters. Here I use [B]bash[/B] and [B]awk[/B]. [code=bash] value1=`awk 'NR==1' data.txt` value2=`awk 'NR==2' data.txt` [/code] If you want to avoid the file on …

Member Avatar for Duoas
0
91
Member Avatar for rocksteady911

Whomever wrote this code was a little confused himself. I suggest you come up with your own solution. [B]p[/B], [B]q[/B], and [B]r[/B] are pointers to characters, not character arrays. The first while loop reverses the string in [B]s[/B][] and puts the result in [B]t[/B][] (but it forgets the null terminator). …

Member Avatar for Aia
0
120
Member Avatar for still_learning

Indeed it is. Consider the following lecture a bonus :icon_cheesygrin: If you plan to use [B]printf[/B] you should [inlinecode]#include <cstdio>[/inlinecode] at the top of your program. Recursive functions are best avoided in languages like C++ because they don't have any form of [B]tail recursion[/B]. Basically, every time you call the …

Member Avatar for WaltP
0
129
Member Avatar for guaild

Windows executables have a flag in the header that causes that console window to appear or not. Try changing [code] int main( int argc, char **argv ) [/code] to [code] #include <windows.h> #include <shellapi.h> int WndMain() { int argc; wchar_t **argv = CommandLineToArgvW( GetCommandLine(), &argc ); [/code] Notice that by …

Member Avatar for guaild
0
322
Member Avatar for jai.mahadeokar

Use the [B]ord[/B] function. [inlinecode]print ord('A')[/inlinecode] Prints the number 65 to the console. Hope this helps.

Member Avatar for jai.mahadeokar
0
106
Member Avatar for step2stepgirl

Actually it is quite vague. To my mind, the most probable meaning is that you are to write a function that takes a vector as argument, finds both the largest and smallest values in the vector, and returns (largest minus smallest). Read another way, you might have to write a …

Member Avatar for Duoas
0
75
Member Avatar for susuoi
Member Avatar for step2stepgirl

Er, I haven't looked entirely through everything, but you seem to have the right idea mostly. Your copy constructor [inlinecode]point::point( point &pnt )[/inlinecode] should not be setting [B]x[/B] and [B]y[/B] to zero, but rather to the same values as the [B]pnt[/B] variable's [B]x[/B] and [B]y[/B]. You also have too many …

Member Avatar for Duoas
0
89
Member Avatar for zandiago

Hey again [B]zandiago[/B]. Watch your syntax. [code=C++] switch (sentence[ i ]) { case 'A': case 'a': total += A; ++numChars; break; case 'C': case 'c': total += C; ++numChars; break; ... } [/code] You are correct in that if a char is not in the switch then nothing is added …

Member Avatar for Ancient Dragon
0
499
Member Avatar for aus_fas1

Is this to be production code? I assume it is so my response might be a little more embarrassingly detailed than you would like... [B]First[/B], for your main problem. I think you are clobbering memory somewhere --I'm actually surprised your program isn't crashing. Try this: [code] filein.read((char *) read_dist, sizeof( …

Member Avatar for aus_fas1
0
249
Member Avatar for redaqen

Actually, you've got things just about right. The problem is that you are calling [B]main()[/B] from the other functions. Don't do that. In between lines 16 and 17 add: [inlinecode] while (TRUE) { [/inlinecode] end the while statement between lines 41 and 42: [inlinecode] } [/inlinecode] Then, get rid of …

Member Avatar for redaqen
0
136

The End.