1,359 Posted Topics

Member Avatar for a2i2

First, as a minor point that you should be aware of, you should never use `void` as the return type of the `main()` function. While earlier versions of the C standard allowed it, it is non-portable; in C++, it is strictly forbidden. Use `int main()` in the future, please. Also, …

Member Avatar for a2i2
0
187
Member Avatar for reyesg

I think you've missed WaltP's point, which was that the counts for each upper and lower case value could simply be added together after the fact.

Member Avatar for WaltP
0
108
Member Avatar for Sendy Hipo

Unfortunately, this approach wouldn't work in any case, at least not in any consistent manner; this is because the integer component of the structure will, in many cases, have an offset to force it to align to a word boundary. This is a system-dependent and compiler-dependent behavior, and would cause …

Member Avatar for Sendy Hipo
0
199
Member Avatar for mrexp21

First off, it would have made much more sense to attach the files to the message itself (using the `Files` menu item in the Daniweb editor window), rather than expect others to go to a different site - one which requires a log in - and download a compressed file, …

Member Avatar for Schol-R-LEA
0
233
Member Avatar for Ouss

OK, so we now know what the program you're working on is supposed to do. What problem are you having with it? Do you know how to write the function, and how to use it once it is written? Are you stuck on some part of it? You must understand, …

Member Avatar for Sendy Hipo
0
306
Member Avatar for vicsong93

I agree with marh; from the look of it, the line should read currentPtr = currentPtr -> Next; A few other comments: * Is this C++ code, or C code? While this code should work under most C++ compilers, the languages are not at all the same. This seems to …

Member Avatar for Schol-R-LEA
-1
196
Member Avatar for DarkMonarch

I assume you are using the system() function to call the C programs. This is the simplest approach, but as you can see, it is rather limited. As it happens, PHP has another built-in function for this purpose, called [exec()](http://webhole.net/2010/03/21/c-plus-plus-php-and-jquery/). It returns an array of strings which contains the standard …

Member Avatar for DarkMonarch
0
245
Member Avatar for opprogrammer

As the other posters say, you haven't explained what problems you are having. We can't do much without more information, I am afraid. I will make a comment, however: with the current version, you are hard-coding a lot of details which could, and probably should, be broken into more general …

Member Avatar for Schol-R-LEA
0
201
Member Avatar for rekedmc

What you need to do is have the CGI script actually generate an HTML page, rather than simply printing back plain text. Can you post the relevant code (using CODE tags if you please)? It would make it much easier to discuss this if we could see the program in …

Member Avatar for WaltP
0
348
Member Avatar for emokidzz

The order of the tests is reversed; you want to increment the base amount first, then check whether it is over the maximum [i]after[/i] the values have been increased. [code]void Heal() { Hp1base += 100; // if the increase goes over the HP max, adjust to the max if ( …

Member Avatar for samuelgray
0
405
Member Avatar for silvercats

Which book, and in what context? Are you certain it wasn't discussing Itanium processors (IA-64, Intel's first attempt at a 64-bit successor to the IA-32 line - better known as x86), rather than x86-64 processors? The former are indeed very different from the x86 series CPUs, but they never gained …

Member Avatar for silvercats
0
168
Member Avatar for scottd82

You may find it worth your while to write a general exponentiation procedure rather than multiplying each time manually. While there is some overhead in a function call, and more in looping to get the result, you need to recall that in a real MIPS CPU (as opposed to SPIM), …

Member Avatar for Schol-R-LEA
0
366
Member Avatar for nijinjose123

First off, there's no such thing as a 'hex value'; there are binary values, some of which represent numeric values and some of which represent character encodings. I presume what you want is to display a binary numeric value in a character string as a hexadecimal number. Let's start with …

Member Avatar for raptr_dflo
0
1K
Member Avatar for GeekZu

[QUOTE=GeekZu;1702301]c++ doesn't support argv[0].[/QUOTE] That shouldn't be the case, even for Turbo C++. Can you post a) the error message you're getting, and b) the [ICODE]main()[/ICODE] function you're using. In order to use the command-line arguments, you need to define the arguments in the [ICODE]main()[/ICODE] function declaration, like so: [code]int …

Member Avatar for eddiecrosby
0
936
Member Avatar for Torf

Let's start with the second one - the one following the [ICODE]main()[/ICODE] function - first. What you have there is a function definition, which gives a name to a function - [ICODE]totalCost()[/ICODE] in this case - and declares the type of the value it returns - [ICODE]double[/ICODE] - and the …

Member Avatar for MandrewP
0
283
Member Avatar for Schol-R-LEA

(Note: This was previously posted at [url]http://www.ruby-forum.com/topic/3426459#new[/url] , but received no responses after four days.) When attempting to install ruby-debug19 on a Windows 7 partition, I have gotten the following error sequence: [code] ERROR: Error installing ruby-debug19: ERROR: Failed to build gem native extension. C:/Ruby193/bin/ruby.exe extconf.rb checking for rb_method_entry_t.called_id in …

0
215
Member Avatar for vyrte
Member Avatar for iamthesgt
0
448
Member Avatar for reallyslick

You say that the program crashes when it exits, which implies that the problem is in how you are cleaning up the program run, most likely in when you are deleting the nodes of the list. Can you post your code where the problem is occurring?

Member Avatar for reallyslick
0
144
Member Avatar for Zvjezdan23

The reason you can't declare the [icode]students[/icode] array the way you have it is because [icode]number_of_students[/icode] is not constant; a statically-allocated array needs to have a constant size at declaration time. Probably the easiest solution is the one you've already got in the structure. which is to use a [icode]vector<string>[/icode] …

Member Avatar for Schol-R-LEA
0
103
Member Avatar for lolwaht

Structures are intended for grouping data together, which can then be worked on as a unit - you can have pointers to structures, pass them as function arguments and returns, etc. Structures make it feasible to work on more complex data structures such as linked lists, trees, heaps, and so …

Member Avatar for mrnutty
0
97
Member Avatar for Karlwakim

[url=http://forums.devshed.com/other-programming-languages-139/compiler-writing-and-new-language-design-634985.html]Compilers[/url] can be written in pretty much any language - I've [url=https://github.com/Schol-R-LEA/Suntiger-Algol]written one in Python[/url], for example - though C and C++ are probably the most commonly used ones. There are some specialized tools specifically for writing parsers and lexical analyzers - the best known being [url=http://en.wikipedia.org/wiki/Lex_%28software%29]LEX[/url] and [url=http://en.wikipedia.org/wiki/Yacc]YACC[/url], and …

Member Avatar for vijayan121
0
198
Member Avatar for Reeseoo

Just how you would do this will depend on the compiler (and IDE) you are using, but in general, you would need to set up a Project (or a Makefile, for compiling from the command line) that would keep track of which files need to be compiled and linked into …

Member Avatar for Reeseoo
0
535
Member Avatar for Kunal0

Given the number of balls in play, it may be better to have a generalized [icode]get_Ball()[/icode] function which take an index argument: [code] int get_Ball(int ball_no) { return balls[ball_no - 1]; }[/code] You could even write it as an [icode]operator[][/icode] function which would allow you to treat it similarly to …

Member Avatar for ravenous
0
288
Member Avatar for Zssffssz

Not as such, no. The standard formats for [url=http://en.wikipedia.org/wiki/Floating_point]floating-point numbers[/url] is such that this wouldn't work. With most x86 compilers, a double is 64 bits long, with one bit for sign, 11 bits for the exponent, and 52 for the significand (that is, the value to the right of the …

Member Avatar for adityatandon
0
268
Member Avatar for ila_asia

Rather than complaining about what you don't know, let's look at what you [i]do[/i] know, and start with that. [list] [*] You need to write a [ICODE]main()[/ICODE] function. [*] You need to define a structure type that holds a person's contact information. An example of what this should look like …

Member Avatar for adityatandon
0
205
Member Avatar for burcinerek

By 'this', you mean to give each student a unique ball? What is actually happening? Has you classwork covered linked lists, or the vector class? This sounds like an exercise aimed at using one of those rather than a basic array (because you can add or remove items from them). …

Member Avatar for vijayan121
0
289
Member Avatar for see_bharath

Now hold on though: the OP referred to C rather than C++. It is possible that this was supposed to be posted in the C forum. While this wouldn't change Narue's answer (or Ancient Dragon's), the replies which assume C++ strings wouldn't apply.

Member Avatar for Schol-R-LEA
1
307
Member Avatar for Chuckleluck

OK, I took the time to download SFML (I was curious about it, anyway, so it wasn't a big deal), and compiled and tested your program. After setting some breakpoints at various places, I found that it is raising a SIGSEGV (that is, a segmentation violation) in the initialization of …

Member Avatar for Chuckleluck
0
710
Member Avatar for BCBTP

No, there isn't any form of numeric literals for binary numbers in C++. Using the bitwise operators as you've shown is probably your best bet, though using hex would probably make more sense than decimal. [code]if((0xb9 & 0x95) == 0x91){ //Do code "0x91" } [/code] The reason why hex makes …

Member Avatar for Schol-R-LEA
0
379
Member Avatar for roona

[url=http://cboard.cprogramming.com/c-programming/144592-cplusplus-code-need-help.html]Cross-posting[/url] is generally frowned upon, as it causes a duplication of effort on the parts of the two groups.

Member Avatar for VernonDozier
0
242
Member Avatar for Tigerwatch

I would attend to the 'walking through walls' issue first, as the solution to the gravity issue will depend on being able to detect the floor. How are you doing [url=http://www.google.com/search?q=collision+detection+3d]collision detection[/url] in general? You might want to go over a few tutorials on the subject such as [url=http://www.flipcode.com/archives/Basic_Collision_Detection.shtml]this one[/url] …

Member Avatar for Tigerwatch
0
162
Member Avatar for lbmve

Before we proceed, could you also tell us the assembly program you are using (e.g., MASM, GAS, NASM, FASM, etc.)? Each assembler uses a different variation on the assembly language syntax, and some of them are quite different from the others. For that matter, while some of the mnemonics you …

Member Avatar for Schol-R-LEA
0
106
Member Avatar for nuclear

On a conceptual level, I would recommend looking into the [I][url=http://www.google.com/search?q=Flyweight+pattern]Flyweight[/url][/I] pattern. The basic principle is to have a class which represents the common aspects of the objects (e.g., sprite sheets) as class members, then have the [I]Flyweight[/I] objects instantiate just the details which the specific object needs (e.g., position, …

Member Avatar for Schol-R-LEA
0
151
Member Avatar for Chuckleluck

What you want to do is have only the class definition in the header, and put the function implementations in yet another file (say, PlayerClass.cpp or something similar). You will need to put the file into your project or Makefile to ensure that it is linked into the executable. Player.h …

Member Avatar for Chuckleluck
0
188
Member Avatar for Zay

If you go back to your original design, [code]#include <iostream> #include<cmath> using namespace std; int main() { int n=4; for ( int i=n;i>0;i--) { for (int space=i; space <n; space++) { cout<<" "; for (int j=1;j<=(2*i-1); j++) cout<<"*"; } cout<<endl; } return 0; } [/code] and modify it, it is …

Member Avatar for Schol-R-LEA
0
189
Member Avatar for esesili

Did you create your project as a CLR project? System::Convert is part of the .Net framework, and only .Net programs (which in C++ means Common Language Runtime programs) can use those classes. Also, did you make sure to include the necessary headers?

Member Avatar for esesili
0
161
Member Avatar for jeevsmyd

What you are looking to do is what is called [i]tokenization[/i], the process of breaking an input stream into tokens. Given the type of data you're working with, it shouldn't be very difficult. The usual solution is to go through the input character by character to find where the current …

Member Avatar for Schol-R-LEA
0
2K
Member Avatar for Raisefamous

While it isn't necessarily how I would do it, it does seem to be a valid approach to the problem. The only thing I see wrong with it is that you need to add the header for [icode]<iostream>[/icode], and a [icode]using namespace std;[/icode] directive. [code]#include <iostream> using namespace std;[/code] If …

Member Avatar for WaltP
0
259
Member Avatar for jackmaverick1

What it is complaining about is the fact that you have the prototypes for the functions, but the functions themselves aren't implemented anywhere. In other words, the functions are [i]declared[/i], but not [i]defined[/i]. You need to have the actual implementation somewhere, either in this file or in another one which …

Member Avatar for jackmaverick1
0
144
Member Avatar for smurfy

Colors are usually represented by three color gradients (either Red-Green-Blue for 'additive color' or Cyan-Yellow-Magenta for 'subtractive color'). This is because the human eye can differentiate three different clusters of wavelengths, with some overlap, so colors 'between' the main detected colors, such as orange, are actually detected by the green …

Member Avatar for nina@cika
0
351
Member Avatar for learner guy

Assuming you are using an [icode]ifstream[/icode] to read the file, then function you want is [url=http://www.cplusplus.com/reference/iostream/istream/seekg/][icode]seekg()[/icode][/url], which allows you to set the 'get pointer' in a file stream (the point at which the next read will begin). If you follow that link, it has an example of how it is …

Member Avatar for Schol-R-LEA
0
241
Member Avatar for acmarshall

[code]string x; string temp[1] = {x}; char y = 0; char key[10] = {y}; string a; string name[1] = {a}; char b = 0; char grade[10] = {b};[/code] This code doesn't make much sense. First off, there is no advantage of declaring an array with a size of one; it …

Member Avatar for acmarshall
0
319
Member Avatar for dinamit3

No, this won't work, you are correct. What you'll need to do is have a large buffer to read the C-string into, then get the size of the string using [icode]strlen()[/icode], and only then should you allocate the memory to hold the word. Alternately, you can use the [icode]string[/icode] class …

Member Avatar for Schol-R-LEA
0
218
Member Avatar for khanthegamer

The problem is occurring because you are using the initialization syntax for what is in fact not initialization. When you are setting the value of a variable that is declared elsewhere, you cannot use the initialization syntax for an assignment, even if you had not yet set the variable. You …

Member Avatar for khanthegamer
0
154
Member Avatar for jeevsmyd

What you need to remember is that both decimal and hexadecimal are only representations of the integer value, which is actually a binary value. Thus, it is only when you go to display the value that it becomes either decimal or hexadecimal, and the same value can be displayed either …

Member Avatar for Schol-R-LEA
0
550
Member Avatar for Tahmod

In the future, please put all code samples inside of code-tags. The forum software does not retain indentation by default, so without the code tags the formatting is lost, making it hard to read the code. Here is your code with suitable formatting (courtesy of [AStyle](http://astyle.sourceforge.net/)): #include <stdio.h> #include <conio.h> …

Member Avatar for Schol-R-LEA
-1
272
Member Avatar for jeevsmyd

According to [url=http://books.google.com/books?id=tVc6VQoxhqkC&pg=PA660&lpg=PA660&dq=turbo+c%2B%2B+3.0+dir.h&source=bl&ots=TsNadwp_DS&sig=JEdZdExVvt7YfOaRU7fRDll4uus&hl=en&sa=X&ei=dZ3sTrLuNIyztwf84fX8CQ&ved=0CC0Q6AEwAjgK#v=onepage&q=turbo%20c%2B%2B%203.0%20dir.h&f=false]this textbook[/url], there is a version of [icode]<iomanip.h>[/icode] in Turbo C++ 3.0. Whether it has all of the manipulators you need is another question (those pages aren't part of the freely available sample), but it should at least have a version of the [icode]hex[/icode] manipulator.

Member Avatar for WaltP
0
178
Member Avatar for jefgreen

No, because the line indicates a fundamental misunderstanding of how variables, characters and integers are (un-)related. If you look at the [url=http://www.asciitable.com]ASCII Table[/url], you will see that the characters which represent the digits are not the same as the integers themselves. What may not seem as clear is that a …

Member Avatar for jefgreen
0
199
Member Avatar for eskimo456

What is [ICODE]timeFactor[/ICODE] for, and under what circumstances is it less than or equal to zero? Also, have you considered making this part of the AI part of the enemy objects themselves, rather than part of the overall code? (I am assuming that Enemy is a class rather than a …

Member Avatar for eskimo456
0
186
Member Avatar for jeevsmyd

[QUOTE=jeevsmyd;1717256]Cant use std::strings .The code should be compatible with turbo C++ v3 .[/QUOTE] Yes, but you are already using [icode]<iostream>[/icode] (without the '.h' extension) and [icode]using namespace std;[/icode], neither of which would work with TC++. Or are you developing with a different compiler first and back-porting it to Turbo C++?

Member Avatar for jeevsmyd
0
810

The End.