Posts
 
Reputation
Joined
Last Seen
Ranked #787
Strength to Increase Rep
+7
Strength to Decrease Rep
-1
80% Quality Score
Upvotes Received
81
Posts with Upvotes
74
Upvoting Members
57
Downvotes Received
29
Posts with Downvotes
17
Downvoting Members
14
19 Commented Posts
10 Endorsements
Ranked #180
Ranked #396
~94.3K People Reached
Favorite Forums

200 Posted Topics

Member Avatar for sureshshan1292

Attempted the things others attempted.. #include <stdio.h> #include <stdbool.h> #include <string.h> void remove_even (int data[], const unsigned int size); void print_spiral (const unsigned int size); static void print_spiral_line (const unsigned int n, const unsigned int line); bool can_be_palindrome (char text[], const unsigned int size, const bool middle_found); /** * Write …

Member Avatar for ekambaram
2
3K
Member Avatar for Aqeel Rafique
Member Avatar for Assembly Guy
-4
138
Member Avatar for vishalonne

You can construct the value of any coin, using coins of lower value (if there are any); this makes the problem easier because the smallest amount of coins required is then obtained by repeatedly paying with the highest value coin, until the remaining cost is 0 (it would be diffent …

Member Avatar for cayman
0
185
Member Avatar for rela

![9f16e3f185e5249f5fccda750957f0ce](/attachments/large/2/9f16e3f185e5249f5fccda750957f0ce.jpg "9f16e3f185e5249f5fccda750957f0ce")

Member Avatar for NathanOliver
0
193
Member Avatar for Joemeister

#include <iostream> #include <string> #include <algorithm> #include <functional> #include <cctype> using namespace std; int main() { /* Assumption: substring may overlap. E.g: "aaa" contains "aa" two times. */ const string HAYSTACK = "abbaabbaabb"; const string NEEDLE = "abba"; int counter = 0; /* A custom compare function for case-insensitive comparing …

Member Avatar for Joemeister
0
2K
Member Avatar for Lloyd_3

#include <iostream> #include <algorithm> #include <vector> #include <functional> using namespace std; /* Just a helper function that prints the contents of the vector, separated by a space */ void print_vector(vector<int> data) { for (auto elem : data) cout << elem << ' '; } /* Uses the <algorithm> function to …

Member Avatar for iamthwee
0
504
Member Avatar for jameslyle2

#include <iostream> #include <string> #include <map> #include <algorithm> using namespace std; int main() { /* Looks like you want something like a bimap, which isn't in the STL */ /* so using a single map here, and swapping the key / value pairs */ /* later to avoid redundancyto some …

Member Avatar for Gonbe
0
232
Member Avatar for Azhagu

#include <assert.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> #include <stdio.h> /******** Stack *********/ const unsigned STACK_INTIAL_ALLOC_SZ = 8; typedef struct { void* elems; /* The elements that are stored in the stack. */ unsigned elem_sz; /* The size in bytes of the elements stored in the stack. */ unsigned size; …

Member Avatar for David W
0
174
Member Avatar for amal.sultan.5855

For C-Strings you could take a look at the [cstring library](http://www.cplusplus.com/reference/cstring/), which contains a function named *strlen*. While you're not looking for a user-defined function, you could also define it yourself as it's quite straight forward. It'd look similar to this: constexpr size_t strlen (const char text[]) { // Note: …

Member Avatar for Gonbe
0
206
Member Avatar for daniela.valkanova

> After its standardization , array size can be specified with a variable. While C supports [VLAs](http://en.wikipedia.org/wiki/Variable-length_array) since the C99 standard, C++ does not support them as can be read in the [standard (8.3.4.1)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf).

Member Avatar for tinstaafl
0
293
Member Avatar for Razahcy
Member Avatar for hariza

> what could we do if theirare more than 10000000000 words? We could then ask this on Daniweb by bumping a 6 year old thread after which we could demolish our computer never to touch one ever again.

Member Avatar for Ancient Dragon
0
2K
Member Avatar for np complete

Do you mean to do something like this? #include <stdio.h> #include <windows.h> static HHOOK _hook; static BOOL _control_pressed = FALSE; static const char _clipboard_text[] = "Hello world!"; static unsigned _clipboard_text_sz = sizeof(_clipboard_text); LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { PKBDLLHOOKSTRUCT kb = (PKBDLLHOOKSTRUCT) lParam; HGLOBAL hGlobal; char* pGlobal; …

Member Avatar for BobS0327
0
250
Member Avatar for jigmey thinley

Right, so you have this figure of a certain height. When looking at the provided example you can clearly see there's some logic behind it; when asked to draw this figure of height 5 you'd be able to do it. So let's start with gathering information. We know how the …

Member Avatar for Gonbe
0
212
Member Avatar for nikzer

> for loop. Is this loop supposed to have a body? Effectively, all it does is set x to 0. But since x = 0, when the program reaches the switch blocks nothing happens. The next for loop forms the body of this loop. > 1) Line 15 is a …

Member Avatar for Gonbe
1
232
Member Avatar for <M/>

#include <stdio.h> #include <ctype.h> #include <string.h> #include <assert.h> #define LINE_WIDTH (15) #define BUFFER_SIZE (1024) char* word_wrap ( char* buffer, const unsigned int buffer_sz, const char* string, const unsigned int string_len, const unsigned int max_line_width) { assert(buffer != NULL && buffer_sz > 0 && string != NULL && string_len > 0 …

Member Avatar for <M/>
0
389
Member Avatar for Razahcy

If `a` is an integer it doesn't (really) make much sense to do it.

Member Avatar for rubberman
0
386
Member Avatar for jackey.jay.9

Something like this? #include <stdio.h> #include <math.h> #include <stdbool.h> #define LOWER_BOUND (0) #define UPPER_BOUND (1000000) // Not inclusive. typedef void (*prime_callback)(unsigned int); static unsigned int digit_prime_count = 0; static const unsigned int M = 10; // Starting from 1. bool is_prime(const unsigned int n) { int i; if (n >= …

Member Avatar for Gonbe
0
180
Member Avatar for max2011

> what is the code to display "*" as pyramid? #include <stdio.h> static void print_n(const char symbol, unsigned int n) { while (n --> 0) printf("%c", symbol); } void print_pyramid(const unsigned int height) { int i = 0, width = 0; const int WIDTH_TOTAL = (2 * height) - 1; …

Member Avatar for Gonbe
0
193
Member Avatar for Razahcy

What is there to explain? `malloc` (attempts to) allocate a given amount of memory on the heap. It doesn't really know (or cares) what you're going to put there so it returns a void pointer so you'll have to cast it to a pointer matching the data you're putting in …

Member Avatar for Razahcy
0
158
Member Avatar for dev90

normally an integer datatype hold 2 byes of memory.If Int is declared it holds 2 bytes by default. This is not true. The amount of bytes an integer takes up depends on the supported word size of the used CPU and there is no "default" specified in the specification. 32-bit …

Member Avatar for sepp2k
0
155
Member Avatar for harde_1

Not having a compiler handy, so treat the following as kind-of pseudo code, but if performance is no requirement you could define it as bool isMono(const tNode* t) { if (t == NULL) return true; else return tsearch(t->info, t->left) == NULL && tsearch(t->info, r->right) == NULL && isMono(t->left) && isMono(r->right); …

Member Avatar for deceptikon
0
309
Member Avatar for nitin1
Member Avatar for deceptikon
-2
114
Member Avatar for ram619

`p` is an array of pointers. `*(p+i)` could be written as `p[i]` and `*(p[i] + j)` could likewise be written as `p[i][j]`. (So `*(*(p+i)+j)` could be written as `p[i][j]`) (and the contents of `p` are offsets off `a` which is 2-dimensional) So you could write that `printf` as: `printf("%d %d …

Member Avatar for ram619
0
231
Member Avatar for ncauchi
Member Avatar for tanatos.daniel

Your code is a mixture of C and C++ conventions, you should choose one or the other. As you posted this in the C section I assume you want C code. What do you want to do with newlines? Do you want to skip them entirely? You also don't have …

Member Avatar for Sokurenko
0
298
Member Avatar for vidya s

#include <stdio.h> int main(void) { const char* string_before = "f a1 2 5 ffffffde 23 fffffff1 4 b0"; const char* string_after = "f a1 2 5 de 23 f1 4 b0"; printf("The C-code resulted in: \"%s\".\n", string_after); return 0; }

Member Avatar for Gonbe
-3
234
Member Avatar for MasterHacker110

I'm not fully sure if I get what you mean with your example, but I think you might be looking for a [map](http://www.cplusplus.com/reference/map/map/)? If not, please be more clear about what you mean with `list[i]` and `list[i_the_second]`.

Member Avatar for MasterHacker110
0
150
Member Avatar for Vinod Supnekar

Relevant fragements from the C(99) specification (http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf): 6.2.4 Storage durations of objects ----------------------------------- The lifetime of an object is the portion of program execution during which storage is guaranteed to be reserved for it. An object exists, has a constant address,25) and retains its last-stored value throughout its lifetime.26) If …

Member Avatar for Gonbe
0
196
Member Avatar for Tinnin

You are comparing indexes to string values. In addition there seemed to be some logic mistakes. Here's an attempt to fix them for you: void fold(char s[], int l) { int i, j, foldHere; i = j = 0; foldHere = FOLDLENGTH; while (i < l) { // We are …

Member Avatar for Tinnin
0
190
Member Avatar for ram619

You print `\n`. Then you print `ab\bcd` on the second line. `\b` is the backspace leaving `acd`. Then you print `\r` which results in going to the start of the current line. Then you print `ef`. The lin already contained `bcd` so it will now contain `efd` with the position …

Member Avatar for Rahul47
0
514
Member Avatar for ram619
Member Avatar for jony_munsi
Member Avatar for Gonbe
-4
122
Member Avatar for avinash.jay.7

Hmm, so you want to count the amount of times an integer is present in a matrix without knowing upfront what integers can be in there? I don't think there's a very beginner-friendly solution for this. I'd probably use a map for it. Below an example: #include <iostream> #include <map> …

Member Avatar for David W
0
2K
Member Avatar for حسنين_1

The factorial of a positive integer n, n!, is `1 * 2 * 3 * ... * n` for n > 0 and 1 for n = 0. Would take you about 1 second to find on google. The simple case is when n = 0, you simply return 1. …

Member Avatar for ddanbe
-1
126
Member Avatar for jandanielsaclolo

#include <stdio.h> void A(float* res) { float a, b; printf("Enter Numbers A: \n"); scanf(" %f %f",&a,&b); (*res) = a+b; } void B(float* res) { float a, b; printf("Enter Numbers B: \n"); scanf(" %f %f", &a, &b); (*res) = a + b; } int main(void) { float total,Ares,Bres; A(&Ares); B(&Bres); total= …

Member Avatar for Gonbe
0
228
Member Avatar for ktsangop

Do you mean something like this? #include <iostream> #include <tuple> #include <vector> #include <string> using namespace std; int main() { typedef tuple <int, string, int, int> pc_data; vector <pc_data> pc_vec; // Add some test data pc_vec.push_back(make_tuple(0, "never gonna ", 0, 0)); pc_vec.push_back(make_tuple(1, "give you ", 1, 0)); pc_vec.push_back(make_tuple(2, "up, never …

Member Avatar for ktsangop
0
6K
Member Avatar for nchy13

If I pass a std::string to the function as pass by value, would it be considered as in-place modification if I don't create any new std::string in modifier function? An algorithm is called "in-place" (or "in-situ") when it works on input using constant, small extra storage space. So yes, it …

Member Avatar for NathanOliver
0
961
Member Avatar for sevin1192
Member Avatar for Lp_baez

string wordEasy[MAX_CHAR]; This will create an array of strings of MAX_CHAR elements. I think you're mixing up C-Strings and string objects. `string wordEasy;` would be what you want here. You could do something like this: if (difficulty == 1) { cout << "Enter a word of your choice that contains …

Member Avatar for David W
0
384
Member Avatar for waqas.zafar.125

At a quick first sight: Replace Player* players= new Player[No_Of_Players]; with players= new Player[No_Of_Players]; Under that add: No_Of_Players = No_Of_Players; (Or: if you want to be more clear about the scope) this->No_Of_Players = No_Of_Players; Also make sure you set a string for "Name" in your constructors. Then your function should …

Member Avatar for David W
0
209
Member Avatar for ??!!

For 3h you could do something like: Time(const unsigned int hours , const unsigned int minutes , const unsigned int seconds) : hours(hours), minutes(minutes), seconds(seconds) { minutes += seconds / 60; seconds = seconds % 60; hours += minutes / 60; minutes = minutes % 60; hours = hours % …

Member Avatar for tinstaafl
-1
349
Member Avatar for rofln

> My tree making algorithm is fine It is not fine. You should look into something called "scope". You're using "new" while it's not needed and you're saving pointers to objects that'll get out of scope when the function returns.

Member Avatar for rofln
0
199
Member Avatar for saurabh.mehta.33234

You are modifying "t" more than once between two sequence points which results in undefined behaviour.

Member Avatar for Unimportant
-1
248
Member Avatar for cocopium

What exactly are the restraints on this task? I assume you can't use negative numbers, otherwise you could write any integer `n` as `-(n - 1) + -(n - 2) + ... + 0 + ... + (n - 1) + n`. You also mentioned the sequences can vary in …

Member Avatar for Gonbe
0
290
Member Avatar for nitin1

O(f(n)+g(n)) = O(max(f(n),g(n)))? is it true ? Hmm been a while since I've done anything with Big O notation but I'll try anyway. No guarentees i'm right as your notation is somewhat unclear to me, especially the right hand side of the equation. Say `f(n) > g(n)`, in this context …

Member Avatar for Gonbe
0
196
Member Avatar for old_apache

> It isn't enitrely clear what sort of help you are looking for. Read: extremely vague.

Member Avatar for old_apache
0
192
Member Avatar for PrimePackster

While there are multiple parts in your code that I find a bit shady, the real mess starts at the "check" and "fill" functions I guess. A very quick look at the fill function reveals this loop: for(int p=0;p<9;) In the other functions you used `break` statements to terminate the …

Member Avatar for Gonbe
0
326
Member Avatar for PolarClaw

Hmm actually wrote something for this a loooong time ago, I'm sure it's very helpful. #include <iostream> #include <vector> #include <iomanip> const int ROWS = 8; // Change "ROWS" to set the height of the pyramid. int v (const std::vector<int>& d, const int n, const int k) { return (k …

Member Avatar for H A hashim
1
1K
Member Avatar for Kareem Klas

Change `++= val;` to `val++;`. (Or if you want harder to read code, remove `++= val;` and change `sum += val;` to `sum += val++;`)

Member Avatar for andreas.bjorn
0
138

The End.