3,183 Posted Topics

Member Avatar for TheRazzle

Sure. You'd wrap the lines in a function and simply call the function when you need those lines to be executed: void show_powerlevel() { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3); cout << "Congratulations your power level is now" << PowerLevel << endl; } ... // Use it like this: show_powerlevel();

Member Avatar for deceptikon
0
140
Member Avatar for DizaFire

Once you're connected to a wifi network, the process of using it is the same as a wired network. Have you read [Beej's guide to network programming](http://beej.us/guide/bgnet/output/html/multipage/index.html) yet?

Member Avatar for deceptikon
0
88
Member Avatar for iqbal2907

How exactly are we talking here, because scanf() is a rather complex function. Ignoring for a moment that there are actually 6 functions in the scanf() family that have a slightly different interface each, the declaration of scanf() itself is like so: int scanf(const char *fmt, ...); The definition will …

Member Avatar for deceptikon
0
899
Member Avatar for mookey2011
Member Avatar for debasisdas
0
55
Member Avatar for fishsticks1907

You create a new list on every iteration of the loop. Move the definition of `ll` outside of the loop and it'll work better.

Member Avatar for fishsticks1907
0
151
Member Avatar for maurinnoe

Well, you could use just a 2D array: int marks[3][5]; // 5 marks for 3 students. But that would be less readable, in my opinion, than an array of structures: struct Student { int marks[5]; }; Student students[3];

Member Avatar for deceptikon
0
37
Member Avatar for I_m_rude

Yes, you can use malloc() to allocate a simulated array of int or char. What were you trying to do that prompted this question?

Member Avatar for I_m_rude
0
182
Member Avatar for chandrutamizh

Daniweb is not rent-a-coder. If you have a question, ask it. If you only want someone to do your homework for you, please be kind enough to piss off.

Member Avatar for deceptikon
-1
47
Member Avatar for shkr

> dfca2345f1278aba11110012567ade21 How do you plan to differentiate between the 5 separate values (according to your structure) in that line?

Member Avatar for deceptikon
0
139
Member Avatar for delta_frost

> If at all there is a differnce between their execution times in the range of nanoseconds or picoseconds? Execution is measured in *"waste of programmer time"* intervals that increase in direct proportion to the triviality of the statement.

Member Avatar for deceptikon
0
189
Member Avatar for rithish

I think the most common options for choosing a pivot are random and median of three. Ideally you want the pivot to be a perfect median of the current subset being sorted, because that produces an optimal recursive tree. Give [this](http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx#quick) a read. It's not perfect, but there's more detail …

Member Avatar for maurya10
0
351
Member Avatar for I_m_rude

"Best" is subjective and dependent on the needs of the situation, but a concise and reasonable generic solution is this one: int count_set_bits(int value) { int n = 0; while (value) { value &= value - 1; ++n; } return n; } The benefit of this algorithm over the more …

Member Avatar for I_m_rude
0
110
Member Avatar for PinoyDev

strtok() is funky in that it works using an internal state through multiple calls. To get the next token you need to call strtok() again with a null first argument (so that it knows to use the previously passed string): output=strtok(input,":"); while(output != NULL) { cout<<output<<endl; output=strtok(NULL,":"); } Oh, and …

Member Avatar for WaltP
0
322
Member Avatar for Vish0203

> The output shows "No error" Probably because there's no error. perror() writes the value of errno in human readable form, along with an optional user provided message. It can literally be implemented like this: /* @description: Maps the error number in errno to an error message. */ void perror(const …

Member Avatar for Vish0203
0
155
Member Avatar for Despairy

How about a lazy update of the cells? It really doesn't matter what the contents of a cell are until you access it for the latest value. Unless the value of a cell depends on all previous cells, you can apply the update as needed rather than en masse, and …

Member Avatar for Despairy
0
299
Member Avatar for daino

What version of Chrome? This might be a stupid question, but did you make sure cookies are enabled?

Member Avatar for daino
0
216
Member Avatar for stengeljjj

cout << fixed << setprecision(7) << space << endl; Don't forget to include <iomanip>, and take care with expectations when it comes to floating point arithmetic. The results are often approximations and can suffer from accumulated errors.

Member Avatar for JasonHippy
0
106
Member Avatar for I_m_rude

Undefined objects or functions will be reported at link time. You might also get a warning during compilation, but link time is the hard stop point.

Member Avatar for deceptikon
0
131
Member Avatar for streetalex310

I'm willing to bet this an encrypted message that students have been given to decrypt as homework.

Member Avatar for ravenous
0
144
Member Avatar for nchy13

I think you've been here long enough to realize that posting code without any kind of specific question will just piss people off, or at best get you ignored.

Member Avatar for deceptikon
0
241
Member Avatar for maurya10

Here's a hint for asking questions: if reproduction of your problem depends on the content of a file, it's a good idea to post a small part of that content along with your code. This way we aren't forced to imagine what your file looks like and devise test cases …

Member Avatar for maurya10
0
281
Member Avatar for nataraja833

> realloc can do that but STL vector does it support ? std::vector has historically not shrunk memory when the size is reduced to improve the performance of furtuer insertions. The idiom from before C++11 was using the swap() member function: vector<T>(a).swap(a); But with the coming of C++11, std::vector now …

Member Avatar for deceptikon
0
139
Member Avatar for ax33m144

> Although I agree that is the proper way to handle something like this, the question says to use nested for-loops. Given that this is the C forum and the link was for a C++ function, I'll go out on a limb and suggest that np complete was recommending that …

Member Avatar for I_m_rude
0
2K
Member Avatar for every1play

> is there any alternative to it? Well, you could read the message and see that strcpy_s() is provided as a "safe" alternative. strcpy_s() is a part of the C11 standard (it's *not* standard at all in C++), but C11 was only ratified in January of this year, so there …

Member Avatar for deceptikon
0
249
Member Avatar for PinoyDev

Why do you think modifying SubtractMe's copy of sum should affect AddMe's copy of sum?

Member Avatar for iamthwee
0
150
Member Avatar for jayram.chandan

A segmentation fault is when you try to access memory outside of your address space, or protected memory that you don't own. It's nearly always the result of a bad pointer or array index value, so checking those values should be your first line of attack.

Member Avatar for jayram.chandan
-1
236
Member Avatar for emmykofi
Member Avatar for Vish0203

It looks okay aside from the class name not being fully qualified in your definitions. They should look like this (notice the template argument is included on the class name): template <class T> T add<T>::sum(T x,T y) { a=x;b=y; return a+b; } template <class T> void add<T>::displaysum() { cout<<endl<<"sum is …

Member Avatar for deceptikon
0
162
Member Avatar for Pugee
Member Avatar for harinath_2007

Video uploads seem emminently impractical to me. On top of the size issue (even small videos are relatively gigantic), and latency of retrieving the files, there's also the problem of playback for various formats. If we implemented something even remotely like this, at the very most it would be tags …

Member Avatar for JorgeM
0
194
Member Avatar for ripplex

That's what you get when you lie to scanf(). Assuming 4 byte integers, `a` looks like this (the question marks mean an indeterminate value): [?][?][?][?] Now when you pass the address of `a` into scanf() and say that it's a pointer to char, scanf() will do exactly what you asked …

Member Avatar for ripplex
0
95
Member Avatar for Vish0203

Since you've sidestepped the command shell's conveniencies like being able to edit your input before sending it to the program, that functionality needs to be duplicated *within* your program. In this case that means recognizing and handling the any special characters that the shell normally handles for you: #include <stdio.h> …

Member Avatar for Vish0203
0
125
Member Avatar for infrapt

It's a very straightforward usage of function pointers. Here's a quikie example using a stack: #include <stdio.h> #include <stddef.h> #define CALLBACK_MAX 10 typedef void (*callback_t)(void); static callback_t callbacks[CALLBACK_MAX]; static size_t n = 0; void register_callback(callback_t callback) { if (n == CALLBACK_MAX) return; callbacks[n++] = callback; } void run_callbacks(void) { while …

Member Avatar for infrapt
0
3K
Member Avatar for aratnon

> but result in console is not same as txt file The line break after each number in your file is a character too. scanf() first reads 'A' and 7 correctly, then prints them. Next it reads '\n' as the character part, but fails the integer part because 'c' isn't …

Member Avatar for deceptikon
0
241
Member Avatar for PinoyDev

> time_t is the number of seconds since 1 Jan 1970 to the specified date. While it is indeed the canonical epoch, there's no guarantee that time_t represent the number of seconds since 1/1/1970. For example, I very seriously considered using 1/1/1900 as the epoch for my time.h library, to …

Member Avatar for deceptikon
0
4K
Member Avatar for I_m_rude

[Beej's Guide](http://beej.us/guide/bgnet/) is pretty much all you'll need.

Member Avatar for deceptikon
0
175
Member Avatar for shashikumar s g

> hii decptikon if ur der please give me a solution I require that you make an attempt first. The problem statement is also ambiguous. Are you reversing the bits in each nibble or swapping the nibbles? Anyway, without actually solving the problem for you, I can help you visualize …

Member Avatar for I_m_rude
0
285
Member Avatar for quiin_aien
Member Avatar for np complete
0
208
Member Avatar for niyasc

> What does the tree look like? Why should that matter? As long as it's a valid binary search tree, the algorithm won't change depending on how the tree looks. > Can anybody share the algorythm to perform inorder traversal of a binary search tree using parent node(without stack or …

Member Avatar for deceptikon
0
162
Member Avatar for shanki himanshu

Members of a structure may be aligned to certain byte boundaries to improve performance or if the platform simply doesn't allow an object of a certain type to begin at any byte. Also, and partially to facilitate alignment, there may be padding between members of a structure or at the …

Member Avatar for I_m_rude
0
107
Member Avatar for Nutster
Member Avatar for fahad.alsharafi.1

> asrockw7 Thanks man. but your adivise for proffissnal not bigiiner like me ^^ Um, no? Breaking a problem down into manageable pieces and experimenting with ideas in a small and controlled environment is programming 101. It's something every beginner should be learning on their first day, and a skill …

Member Avatar for deceptikon
0
133
Member Avatar for PinoyDev

Take a look at the ctime header. It includes types and functions for manipulating dates and times. With minimal effort you can parse your time string into a tm structure, convert those into time_t objects with mktime(), and finally get the difference with difftime().

Member Avatar for deceptikon
0
433
Member Avatar for Remzz

> I'm curious how these two approches actually test for valid values. At least for strtod(), a combination of the return value and end pointer as the second argument can be used to validate the string. If conversion stopped before the end of the string, then it's not valid. I'm …

Member Avatar for Remzz
0
210
Member Avatar for gemanthony.gonzales
Member Avatar for I_m_rude
0
215
Member Avatar for ryantroop

There's already an optional comment for votes that also applies reputation points. When you click on either an up or down arrow, the comment box will pop up.

Member Avatar for Dani
0
162
Member Avatar for Shashank clic

> Yes, but it's not built in to the language or standard libraries. Actually, it is as of C11. Though the trick with the latest standard is finding an implementation of it. Hopefully C11 will be more widely adopted than C99. ;)

Member Avatar for nmaillet
0
110
Member Avatar for Dani

Oddly enough, I think I'm in favor of option 2. Though there would definitely need to be a way to hide excess numbers of comments. It's rare currently, but if the reputation system is used more often because of this feature, that kind of thing might become more common.

Member Avatar for Dani
0
128
Member Avatar for Ancient Dragon
Member Avatar for gerbil
0
230
Member Avatar for misi

Our permission/ranking system isn't strictly by post count. Specifically, the difference here is between a Newbie Poster and a Community Member. Once you've reached the threshold of either 15 reputation points or 5 posts plus 5 days since joining, your rank will automatically go from Newbie Member to Community Member. …

Member Avatar for misi
0
146

The End.