3,183 Posted Topics

Member Avatar for dwarvenassassin

You're not doing anything wrong. Windows Forms is notorious for having a noticeably slow redraw out of the box. There are a number of ways to improve matters, but the list is kind of long, so I'll just suggest searching google. One thing to keep in mind is that C# …

Member Avatar for Momerath
0
195
Member Avatar for student_learner

It's the preprocessor's pastie operator. It takes two tokens and concatenates them into a single token. For example: [code] #include <stdio.h> #define PASTIE(prefix, var) prefix ## var int main(void) { char const* strFoo = "foo!"; puts(PASTIE(str, Foo)); return 0; } [/code] Neither str nor Foo are meaningful by themselves, but …

Member Avatar for student_learner
0
145
Member Avatar for mweshk

Structurally the program makes no sense. main() is embedded inside circle, and circle isn't properly terminated. name is a variable local to main() but it's being used as a member of circle. This compiles, but I didn't run it: [code] #include <iostream> #include <iomanip> #include <cmath> using namespace std; struct …

Member Avatar for deceptikon
0
136
Member Avatar for solarcoder

If the seed is always the same, the pseudorandom sequence will always be the same. Change the seed to something other than 8, and A will probably be different.

Member Avatar for deceptikon
0
106
Member Avatar for eldes23

Where is your avatars folder relative to the root folder? If the file is there, it sounds like the problem is as simple as getting the path correct in your img tag.

Member Avatar for eldes23
0
216
Member Avatar for kikic
Member Avatar for caltech

[QUOTE]I'm pretty much all lost/braindead on step 6. [/QUOTE] It's a variation of the algorithm for checking if an array is sorted. If it's not sorted in ascending or descending order, the profits fluctuated, which is pretty easy to check: [code] #include <iostream> #include <string> using namespace std; string ProfitTrend(int …

Member Avatar for caltech
0
141
Member Avatar for cajohnson

Your printword() function is making the results look different from the paper. Try this instead: [code] void printword(WORD A) { printf("%08X ", A); } [/code]

Member Avatar for cajohnson
0
212
Member Avatar for faraz ahmad

The code continually allocates new memory to ptr, which leaks away the previous memory and loses any previously assigned numbers. Rather than outline all of the possible cases and explain why they're necessary, I'll just give you a function to study: [code] bool ResizeArray(int*& a, unsigned old_size = 0, unsigned …

Member Avatar for MastAvalons
0
343
Member Avatar for tom12

I can't reproduce your problem, it encrypts the whole sentence for me. What compiler and OS are you using?

Member Avatar for tom12
0
196
Member Avatar for sharath_137

You can get details about what happened after fopen() failure like this: [code] FILE* tmpfile = fopen(xxxxxx, "r"); if (!tmpfile) { perror("Error opening file"); } [/code]

Member Avatar for Ancient Dragon
0
94
Member Avatar for mBrissman

Uninitialized pointers are not pointers to infinite memory. You have to allocate memory before trying to write to it: [code] #include <stdio.h> #include <stdlib.h> int main(void) { struct Person { char *firstName; char *lastName; }; struct Person newPerson; newPerson.firstName = malloc(50); newPerson.lastName = malloc(50); printf("Enter your first name and last …

Member Avatar for mBrissman
0
1K
Member Avatar for navinrahim

Yes, there are more corrections. How many more depends on the compiler you're using, because this code makes assumptions about the language that aren't supported by modern compilers. But if you ignore those problems, there are four corrections required to make the code compilable. You have options in what corrections …

Member Avatar for deceptikon
0
145
Member Avatar for gourav1

[QUOTE=gourav1;1763824]damn awsome links. simply saying "superb info". and i am still not getting my second question....."second question is that : when i don't give "\n" with the statement(number 12) (scanf("%d\n",&t), then it skip the gets() statement in the while loop , but when i give "\n" then it works properly..please …

Member Avatar for deceptikon
0
239
Member Avatar for solarcoder

[QUOTE]I am stuck in how does cin.clear() and cin.ignore(200, '\n') work[/QUOTE] cin.clear() resets the error state of the cin object. So if any of cin.eof(), cin.fail(), or cin.bad() return true, they'll return false after calling cin.clear(). The reason you need to call cin.clear() is because until the error state is …

Member Avatar for deceptikon
0
156
Member Avatar for qualt

[URL="http://onecore.net/creating-standalone-graphics-programs.htm"]This[/URL] seems relevant.

Member Avatar for qualt
0
347
Member Avatar for fr0st003
Member Avatar for free2move

When you say you "can't use arrays", what exactly does that mean? Because it's quite impossible to sort anything when you can't retain it, and while you can use 25 variables to get the same effect as an array, that's totally insane. I can't imagine a teacher expecting you to …

Member Avatar for free2move
0
2K
Member Avatar for kingsonprisonic
Member Avatar for Jay22

The error says it all: regular functions cannot be nested in C++. Move your definition of selectionSort() outside of main() and call it in case 7 instead.

Member Avatar for Jay22
0
217
Member Avatar for thorn101

There's no difference at all. The array notation for a function parameter is just syntactic sugar. Internally it's treated as a pointer, and you can use it as a pointer, which does indeed include pointer arithmetic: [code] #include <stdio.h> void traverse(int a[], int n) { while (--n >= 0) { …

Member Avatar for deceptikon
0
163
Member Avatar for zee93

If you need that kind of control over the user experience, I'd say write a GUI-based program instead of a console program.

Member Avatar for deceptikon
0
3K
Member Avatar for accra
Member Avatar for ilearnz001

[URL="http://beej.us/guide/bgnet/"]Beej's guide[/URL] has been the recommended first stop for many years. I'd recommend purchasing the book for offline reading too, 'tis worth it even though the book is rather thin. :)

Member Avatar for deceptikon
0
113
Member Avatar for M.Waqas Aslam

[QUOTE]is there is any other language which is safe from decompiling[/QUOTE] Better question: Why are you worried about decompiling?

Member Avatar for jwenting
0
302
Member Avatar for Labdabeta

Language lawyers can argue a few reasons why that would fail, but in practice it's all but guaranteed to work.

Member Avatar for rubberman
0
151
Member Avatar for manoj_93

[QUOTE]Is a=b+c+d considered as one instruction or 2 instructions?[/QUOTE] Neither. Barring compiler optimizations, there are three operations going: two additions and an assignment. As far as instructions go, a naive interpretation would be: [CODE]mov r1, b mov r2, c add mov r2, d ; Assuming add puts the result in …

Member Avatar for tungnk1993
0
150
Member Avatar for jayhall

The simplest solution would be to make subsequent queries into your table for the make, excluding the id that you're already displaying, and order the results by price. Then you can insert those into your expanded rows display. Alternatively, depending on the size of the table, cost of database queries, …

Member Avatar for diafol
0
661
Member Avatar for Ahmed2

[QUOTE]the title says it all[/QUOTE] If by "says it all" you mean that it says one can ignore your thread due to lack of information, I'd agree. :D Since I know jack squat about CDF, I'll just try to answer what I think is your question. [QUOTE]What I know is …

Member Avatar for deceptikon
0
620
Member Avatar for The_Purple_Mask

[QUOTE]Is there a point writing my own heap for time optimization?[/QUOTE] It's pretty unlikely that an ad hoc heap would be faster than std::priority_queue. Not to mention the effort of reinventing the wheel *and* the huge risk of bugs in your implementation that just aren't there with an existing oft …

Member Avatar for mike_2000_17
0
268
Member Avatar for jeyjey223

It's also probably not a good idea to clear the screen after every iteration of the loop without some kind of pause involved. The program will run too quickly to see the changes and will look like it's just printing a single random number.

Member Avatar for deceptikon
0
105
Member Avatar for dbsp

The problem is not with fgets() reading a newline character, it's with scanf() leaving a newline character in the stream for fgets() to read. To fix the problem, change how you're using scanf(), or use a different method of input. There are two common recommendations. First, you can avoid scanf() …

Member Avatar for deceptikon
0
3K
Member Avatar for Esmerelda

[QUOTE=Esmerelda;1748323]ok..then c=++a + ++a + ++a should give the output c=24 but its c=22. ???[/QUOTE] Undefined behavior is the Schrödinger's cat of programming. The result of an undefined expression could be anything until you actually run it, and the result you get in practice depends on too many factors to …

Member Avatar for WaltP
0
295
Member Avatar for meetjatin88

This game is an amusing diversion. Like Ali 2101 said, kbhit() is the easiest way to check for a key press in compilers that support it. You can also fake kbhit() with the Win32 API, but that's not necessary in this case. Here's a sample game that does something similar: …

Member Avatar for deceptikon
0
271
Member Avatar for taurusone

Your question is ambiguous. Please provide an example with input and the desired result.

Member Avatar for thines01
0
102
Member Avatar for rithish

strcmp returns the difference of the two strings. If the first string is "less" than the second string it returns a value less than 0. If the first string is "greater" than the second string it returns a value greater than 0. And if the two strings are identical, it …

Member Avatar for deceptikon
0
103
Member Avatar for student_learner

p is a pointer to char, not int. So when you increment by 1, it increments by 1 byte instead of the number of bytes in an int. I think you should throw that book away if that program is a sample of its quality.

Member Avatar for DeanMSands3
0
233
Member Avatar for C++ programmer

None of those are standard C++ functions. What library are you using to get them, or what compiler are you using if they're extended library functions?

Member Avatar for deceptikon
0
731
Member Avatar for andrewpw

[QUOTE]Every time I run my program, and enter a character, my program prints the correct output (for example if I enter 'n' the first time, my program outputs "you've deposited 5 cents"), but then it also outputs the default message every time ("Whoops you've entered the wrong command, please try …

Member Avatar for Gaiety
0
3K
Member Avatar for radiat

One example: You may want the lifetime of the object to not be restricted to the scope in which it was declared. Dynamic memory has a lifetime of when you allocate it to when you release it.

Member Avatar for radiat
0
126
Member Avatar for Walther1366

Be aware that 2 digit dates *will* cause overlap between the 1900s and the 2000s, but if you have a hard lower bound on the 1900s, like 1970, you can check for that explicitly and be good until the same year in the 2000s: [code] // Works until 2070 if …

Member Avatar for Walther1366
0
180
Member Avatar for Labdabeta

std::vector and std::string do a lot of work internally. You'd probably be better off converting the 'what' instead of the 'how'. Ask yourself what the code is trying to accomplish and write C code to do it.

Member Avatar for Ancient Dragon
0
179
Member Avatar for LisaMcOsker
Re: c#

age is never set to anything other than 0. What you probably wanted was something more like this: [code] int age; Console.Write("Please enter your age: "); if (int.TryParse(Console.ReadLine(), out age)) { if (age >= 65) { Console.WriteLine("You are entitled to discount"); Console.ReadKey(true); } else { Console.WriteLine("You are not entitled to …

Member Avatar for deceptikon
0
92
Member Avatar for Labdabeta

It's not possible without writing your own preprocessor that adds appropriate escape characters for the stringizing operator.

Member Avatar for Labdabeta
0
290
Member Avatar for Vasthor

I'd say continue where you left off, and review previous chapters as necessary.

Member Avatar for thines01
0
143
Member Avatar for Aarowaim

You're probably using cin like [ICODE]cin >> s[/ICODE]. That method stops reading at whitespace, so s is only populated with the first word from input. If that's the case then it has nothing to do with how the code copies to the clipboard, and you can fix it by reading …

Member Avatar for Aarowaim
0
274
Member Avatar for arold10

[QUOTE][CODE]scanf("%d", &hourlyRate);[/CODE][/QUOTE] %d is for integer input. For double input use %lf. [QUOTE][CODE]printf( "Miles gallons was %d\n\n", salary );[/CODE][/QUOTE] Just like scanf(), printf() expects you to tell the truth about what type of variable is being printed. salary is a double, but %d says that it's an int. That technically …

Member Avatar for arold10
0
201
Member Avatar for s_mostafa_h

Perhaps consider something more like this: [code] string GridToXml(DataGridView source, string root, string element) { var doc = new XmlDocument(); doc.LoadXml("<" + root + " />"); foreach (var row in source.Rows) { var element = doc.CreateElement(element); foreach (var cell in row.Cells) { element.AppendChild(doc.CreateElement(cell.OwningColumn.HeaderText)); element.LastChild.InnerText = cell.FormattedValue; } doc.Firstchild.AppendChild(element); } return …

Member Avatar for s_mostafa_h
0
2K
Member Avatar for srijan1990
Member Avatar for profyou

[QUOTE]I have been trying to take input until empty string is entered(simply press enter) ?[/QUOTE] The >> operator doesn't recognize whitespace except as a delimiter on both sides. If you just press enter, it's ignored while the >> operator waits for non-whitespace. To check for a blank line you would …

Member Avatar for deceptikon
0
181

The End.