Posts
 
Reputation
Joined
Last Seen
Ranked #781
Strength to Increase Rep
+6
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
~93.3K People Reached
Favorite Forums
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
136
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
182
Member Avatar for rela

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

Member Avatar for NathanOliver
0
190
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
501
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
229
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
170
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
204
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
291
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
248
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
210
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
227
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
386
Member Avatar for Razahcy

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

Member Avatar for rubberman
0
337
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
175
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
191
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
155
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
151
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
306
Member Avatar for nitin1
Member Avatar for deceptikon
-2
112
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
228
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
293
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
232
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
147
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
193
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
186