1,359 Posted Topics

Member Avatar for new_developer

Before we get to the specific issue, I'd like to mention a few things. First, it is incorrect to use `void ` as the return type of the `main()` function; according to the C++ language standard, you should always use `int main()`. Some compilers do allow `void main()`, but strictly …

Member Avatar for Lucaci Andrew
0
167
Member Avatar for ztdep

What have you tried so far? Show us your code - or just some pseudo-code - and we'll help you debug it. If you aren't sure where to start, start by figuring out how you are going to read in a given line of text and parse it. I recommend …

Member Avatar for Branickiod
0
114
Member Avatar for jemz

On the one hand, I agree with veedoo regarding the use of a general-purpose editor; it is often better to have one editor which you are well-familiarized with, than to jump between different editors based on the language. OTOH, there are always circumstances where you won't be able to use …

Member Avatar for Lucaci Andrew
0
319
Member Avatar for summer_21

Could you tell us more about what you've tried already? I know that it isn't C, but you might want to look at the circuit simulation code in Chapter 3 of [*Structure and Interpretation of Computer Programs*](http://mitpress.mit.edu/sicp/). It goes into detail about how the circuit connections can be implemented, and …

Member Avatar for dheaven
0
783
Member Avatar for dwhite12

To post a code sample, you can use the Code button on the editing bar just above the editing pane. This should open up a new window where you can paste the code samples. Alternately, you can simply indent the line four spaces, with extra lines between the code and …

Member Avatar for Lucaci Andrew
0
249
Member Avatar for Perry31

Programmatically, you mean? What is your intention with it? If this is a one-time deal, you might be better off just using the hex editor. Also, what compiler are you using, and does it have any sort of library available for this purpose? Do you you intend to manipulate the …

Member Avatar for Schol-R-LEA
0
172
Member Avatar for poloblue

Again with putting code in the header files... *sigh*. Worse, it is now clear that this horrible practice is being perpetrated and perpetuated by your instructor, who apparently wrote the majority of said code in this fashion, leaving only sections for you to fill out. <rant> Either your professor is …

Member Avatar for Schol-R-LEA
1
1K
Member Avatar for abrarsyed

First off, stop using the SMS abbreviations; no one will take you seriously here if you insist on that sort of thing. Write out clear, complete English sentences, to the best of your ability, please. Second, while I know it is a picayune point to make, `void main()` is not …

Member Avatar for abrarsyed
0
550
Member Avatar for pooh1234qwerty

In addition to Trentacle's questions, I would also ask, what compiler are you using, under what kind of system? The reason I ask is because, while a ten million item array is almost certainly excessive, it should be *possible* to declare and use one under a modern 32-bit or 64-bit …

Member Avatar for pooh1234qwerty
0
188
Member Avatar for hisan
Member Avatar for johnadamson

I would recommend starting off with the representation of the deck of cards. Have you studied classes and object-oriented programming yet? If you have, then the easy thing to do is create a class Card, which can have one of the 52 face and suit values, then use that to …

Member Avatar for Schol-R-LEA
0
481
Member Avatar for poloblue

To get the crux of the problem, take another look at what the `for()` loop does in each of it's four parts. Here is a simplified version of the [BNF](http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form) grammar of the `for()` expression: <for_loop> ::= 'for (' <initialization> ';' <conditional> ';' <increment> ')' <body> Compare this to the …

Member Avatar for TrustyTony
0
213
Member Avatar for poloblue

OK, first things first: I know that you were probably instructed to put the functions in the header file, but in fact you only want the function *prototypes* declared there; you'll want to put the actual functions in a third file, which would then be linked into the program at …

Member Avatar for poloblue
0
506
Member Avatar for c_parse

The structure as given makes no sense; I suspect what you want is more on the order of this: typedef struct dynamic_array { size_t array_size; int* array; } DYNAMIC_ARRAY; The idea here is that you have a `size_t` variable to hold the number of elements in the array, and then …

Member Avatar for Schol-R-LEA
0
216
Member Avatar for triumphost

I would actually recommend using [template specialization](https://www.google.com/webhp?source=search_app#q=template+specialization&fp=1) and the [string::find()](http://www.cplusplus.com/reference/string/string/find/) method instead: template<> bool CustomType<std::string>::Contains(const std::string& literal, bool CaseSensitive) { std::string s(literal); if (!CaseSensitive) { for (size_t i; i < s.size(); i++) { s[i] = tolower(s[i]); } } return this->find(s); } template<> bool CustomType<char *>::Contains(const char* literal, bool CaseSensitive) { …

Member Avatar for Schol-R-LEA
0
842
Member Avatar for Bencz

OK, let's start with the basics. In general, the first step in parsing a stream of text is to break the text up into lexemes (tokens), right? So, what you want to do is work out the basic components of the input format, write a simple lexical analyzer to tokenize …

Member Avatar for Schol-R-LEA
0
199
Member Avatar for Dudearoo

Actually, there's still a problem with it; the [formatting string](http://www.cplusplus.com/reference/clibrary/ctime/strftime/) is incorrect, which means that the time string never gets created. The correct format should be `"%I"` for hours (12-hour format) and `"%M"` for minutes. Try the following: #include <iostream> #include <cstdio> #include <ctime> using namespace std; const int Buffer_Size …

Member Avatar for Dudearoo
0
210
Member Avatar for LatSo

Ordinarily, the best solution for primes under about 1 million would be to use the [Sieve of Eratosthenes](https://www.google.com/search?q=sieve+of+eratosthenes) to generate all of the primes from 2 to the upper bound number. Given that the sieve *requires* that you start at 2, however, it may not be what your professor is …

Member Avatar for LatSo
0
712
Member Avatar for Perry31

The reasons why it is crashing is quite simple: first off, you are only allocating one structure's worth of memory in your call to `calloc()`. When you try to access the (non-existent) second structure, you run off the end of the allocated array, causing a memory protection violation. My recommendation …

Member Avatar for Perry31
0
98
Member Avatar for CharlieBrook

I am somewhat puzzled by the use of this loop to print out the two different strings in `card[][]`: for(int x=0;x<19;x++) { printf("%c",card[i][x]); if(card[i][x] == ':') { fgets(&face[i],3,stdin); } } Wouldn't it be just as easy to use printf("Enter suit value for %s ", card[i]); face[i] = getchar(); getchar(); /* …

Member Avatar for Ancient Dragon
0
239
Member Avatar for danielgek

While I have only looked at this briefly, I can tell you that the main problem stems from this error here: > main.c|75|warning: implicit declaration of function '`get_endereco`'| What this means is that you haven't declared the function `get_endereco()` at that point of the source file yet, and the compiler …

Member Avatar for danielgek
0
247
Member Avatar for reenarankawat

In the absence of the necesary information from the OP, I can only make broad suggestions, with the number one recommendation being to replace all of these repetitive tests with a table and simple loop. struct Q_and_A { std::string question; std::string options[3]; char answer; int points; }; Q_and_A exam[] = …

Member Avatar for Schol-R-LEA
0
6K
Member Avatar for shiushiu

First off, we don't do other people's homework for them. Second, we don't do other people's homework for them. And third, we don't do other people's homework for them. Sensing a pattern here yet? No one here will simply hand you a solution on a silver platter. If you show …

Member Avatar for Schol-R-LEA
0
152
Member Avatar for Sendy Hipo

lucaciandrew: I have to disagree with you on this - the fully qualified `std::string` is generally preferable to `using namespace std;`, especially inside headers. Headers get included in multiple locations, some of which could present namespace collisions if you have the `std` namespace (or any other, for that matter) used …

Member Avatar for Sendy Hipo
0
708
Member Avatar for poloblue

OK, what problem are you having? The code your instructor provides is pretty straightforward (if a bit [BFI](http://www.catb.org/jargon/html/B/brute-force-and-ignorance.html), presumably on purpose) and should be easy to extend. Where is the issue, and what is it doing wrong?

Member Avatar for Lucaci Andrew
0
301
Member Avatar for valestrom

Looking at [this page in MSDN](http://msdn.microsoft.com/en-us/library/x70d7t0y.aspx#Y0) I believe you want to use either `Convert::ToString(makebreak)` or the equivalent `Int32::ToString(makebreak)`.

Member Avatar for valestrom
0
3K
Member Avatar for oscargrower11

While the point about your code was broadly speaking correct, the explanation given is a bit off. It isn't so much how the *pointer* was declared or assigned as much as it is about how the *memory* it points to was allocated, and how long you need that memory to …

Member Avatar for Lucaci Andrew
0
567
Member Avatar for Albino

It's very unlikely that the characters are going to appear as you want them to, for a console application. You would need a [code page](http://en.wikipedia.org/wiki/Code_page) which has the appropriate glyphs, mapped to the correct Unicode [code points](http://en.wikipedia.org/wiki/Code_point). While there are Unicode code pages for UTF-7, UTF-8, and UTF-16, I don't …

Member Avatar for Albino
0
279
Member Avatar for lotusdream

First off, you might want to use [`calloc()`](http://www.cplusplus.com/reference/clibrary/cstdlib/calloc/) rather than `malloc()` for allocating arrays: ascii=(int *)calloc(24000, sizeof(int)); It's a minor point, as there is no real difference in it result-wise, but it does make it clearer what your intent is. Also, you are allocating memory and having `enc` and `dec` …

Member Avatar for Schol-R-LEA
0
392
Member Avatar for Rodney J

Can you please tell us what you need help with? Aside from indent style issues, I mean.

Member Avatar for Schol-R-LEA
0
313
Member Avatar for Sendy Hipo

Could you tell us what the errors you are getting are, as well as which compiler and platform you are using? One thing I will recommend right off the bat is to remove the `using namespace std;` from both the header and the implementation file for your class, and explicitly …

Member Avatar for Sendy Hipo
0
215
Member Avatar for sameerge

As Deceptikon says, the languages themselves are not software at all. Presumably, what you want to know about are the translators - compilers and interpreters - which implement the languages. The answer is, 'yes'. Whether they are system software or application software is entirely a matter of point of view. …

Member Avatar for WaltP
0
219
Member Avatar for Valiantangel

Well, first off, it isn't really the case that composition is *superior* to inheritance, so much as that they are useful for different things, and that inheritance lends itself to misuse more than composition does. The real knock against inheritance is about '[spaghetti inheritance](http://catb.org/jargon/html/S/spaghetti-inheritance.html)', which is where you are inheriting …

Member Avatar for stultuske
0
98
Member Avatar for new_developer

The `endl` manipulator has the effect of forcing a newline. If you remove it from the output line, and put it after the end of the loop, it should give the desired result: for(int i=0; i <= 10; i++) { cout << i; if (i < 10) { cout << …

Member Avatar for new_developer
0
1K
Member Avatar for kuki123

Which DBMS are you using? Most modern database engines have some sort of support for autoincrementing integers, which would make a lot more sense for most purposes than a text field as a primary key.

Member Avatar for Schol-R-LEA
0
185
Member Avatar for poloblue

First off, you want to change how you are setting the first day of the month. Right now, you have a fixed offset for the first day, and are then using that same offset for each successive day of the month, causing them to be printed at intervals of 36 …

Member Avatar for Schol-R-LEA
0
401
Member Avatar for funkey100

Calling `main()` explicitly is an extremely poor idea; in fact, it is actually forbidden in the C++ standard, and the compiler ought to be giving you an error message on that (not that all compilers do). The `main()` function is special in a number of ways - it performs a …

Member Avatar for Schol-R-LEA
0
313
Member Avatar for Perry31

There are a number of mistakes in this code, starting with the use of `void main()` rather than `int main()`. While the older C standard allows for it, it is a non-portable variant, and the IIRC newest version of the standard closes that loophole by requiring `main()` to return an …

Member Avatar for DeanMSands3
0
8K
Member Avatar for juliermills

First off, they are completely unrelated languages; Java was developed out of a language called Oak by Sun Microsystems, while JavaScript was created by Netscape Communications. while they share some common syntax, most of that commonality was inherited independently from C++. 'JavaScript' isn't even the original name of the language …

Member Avatar for Akill10
0
229
Member Avatar for Transcendent

Best is awfully subjective, but I can make a few suggestions. To start with, the [main Python site](http://www.python.org) actually has some excellent tutorials, as well as all of the documentation references for the language. The [Dive Into Python](http://www.diveintopython.net/) online text is a good one if you are already familiar with …

Member Avatar for vkaravir
0
225
Member Avatar for Patiodude

Ah, now this is a different question. In C/C++, any given *program* must have exactly one `main()` function, but a program may span as many *files* as you like, and not all source files must have a `main()` - indeed, most source files won't, for the majority of non-trivial projects. …

Member Avatar for VernonDozier
0
189
Member Avatar for Jackk123

The main thing I am seeing here is that you are trying to save the characters to `int` variables, rather than `char`. While it is true that the standard `char` type is only 8 bits wide, and thus would not be able to hold the multi-byte characters, using an `int` …

Member Avatar for Jackk123
0
889
Member Avatar for zemzela

[Cross-posted to DevShed](http://forums.devshed.com/other-programming-languages-139/task-in-assembler-8086t-909850.html#post2786932) [Also Warrior Forums](http://www.warriorforum.com/programming-talk/609727-task-assembler-8086-a.html) I posted some comments on the DevShed thread which I hope you'll find useful; I would repost them here, but it would just be a waste of the disk space for Daniweb to duplicate it. Suffice it to say, you need to give us …

Member Avatar for Schol-R-LEA
0
282
Member Avatar for tubzz

We can help you debug the program, certainly. We won't 'help' you by doing it for you. The code as given is far from a working program; the most obvious problem with is the inconsistent use of capitalization, which in a case-sensitive language is an error. That is to say, …

Member Avatar for deceptikon
0
674
Member Avatar for coffecat

On a casual scan, I see that the section where you test for the input value being a letter can be simplified by using the [`isalpha()` function](http://www.cplusplus.com/reference/clibrary/cctype/isalpha/) (actually, it's usually implemented as a macro, but that's besides the point). while (isalpha(inpLetter)); On a related note, the [`toupper()`](http://www.cplusplus.com/reference/clibrary/cctype/toupper/) and [`tolower()`](http://www.cplusplus.com/reference/clibrary/cctype/tolower/) functions …

Member Avatar for Schol-R-LEA
0
324
Member Avatar for j509

OK, sounds like a good project to work on. What have you done with it so far?

Member Avatar for j509
0
962
Member Avatar for phorce

Setting the overall goal aside for the time being, what it sounds like is that you want help in processing [command-line arguments](http://www.crasseux.com/books/ctutorial/argc-and-argv.html). While the details of this can be rather tricky, the basics are fairly straightforward. In C and C++, command-line arguments are passed to the program as a pair …

Member Avatar for Schol-R-LEA
0
136
Member Avatar for Th3_M4TriX

The MOV instruction is for moving (copying, actually) a value from one memory location to another (or from memory to a fast register, which is sort of special kind of memory for performing operations in quickly and for holding special values the system needs to keep track of, or vice …

Member Avatar for Schol-R-LEA
0
327
Member Avatar for Zvjezdan23

How is it getting corrupted? Just what is the problem behavior? Now, I should mention that the way you have the `for()` loops indexed is potentially problematic, because you are starting at 10 on each of them. Why would this be a problem? Because a ten-element array would have indices …

Member Avatar for DeanMSands3
0
136
Member Avatar for Dasttann777

I have to agree with WaltP; if you are writing a simple program that resembles a language interpreter, and it is capable of computing non-trivial equations of more than a fixed size, then you really are talking about writing an intepreter. You'll want to go the whole route of tokenizing …

Member Avatar for m4ster_r0shi
0
169

The End.