give me an example of malloc() function using sbrk.?
104982
I'm not sure I correctly understand the question,\nbut if you want an example of "malloc()" which\nuses "sbrk()" in it's implementation, almost *any*\nwill do.\n\n"malloc()" either directly or indirectly will call\n"sbrk()" whenever a heap allocation is requested\nwhich can not be fulfilled by a free buffer in the\nexisting memory pool.  In that case, sbrk() is used\nto request another "chunk" of virtual memory from\nthe OS.\n\nAs a concrete example, look at the OpenSolaris source.\nNote reference #1 where "malloc" calls\n"_malloc_unlocked()" [see reference #2].\n\nIf there isn't sufficient space within the existing\nheap pool, then "_morecore()" is called at line\n256 (see reference #3).  \n\n"_morecore()" invokes the "GETCORE()" macro at \nline 629.  GETCORE is simply an alias for\n"sbrk", see line 164 in reference #3.
288451
in c:\nchar name[20];\nfor(i=0;i<=20;i++)\n  {\n   scanf("%c",&name[i];\n   }\nfor(;i>=20;i--)\n {\n  printf("%c");\n};\ni think this will wrk;\nthe logic is jst accept the name into a char array and start reading back.
740430
You are you using a a pointer and an array while passing a variable to a function called Point. I'm not quite sure what you are trying to point to, but you are copying the heap.
447556
Look up "quicksort".\n\nIt fits very naturally into a recursive implementation\nand is also a very efficient sorting algorithm.\n\nI've included a link to the Solaris source for quicksort.\nIt is written in C (rather than C++).  It is somewhat\ncomplicated because it optimizes the sorting of\nshort sequences by switching to an insertion sort.\nHowever, you could implement a simpler version which\nran quicksort all the way to completion.
1030606
Randome Access Memory
326706
var\nP : Array[0..10,11..20] of Pointer;
363476
There's not enough information, what type of list, I don't think you mean an Enumerated List, and into what type of split, are you talking about linked lists, or something like indexing using trees to navigate or manage keys?
1159892
Sequential search:\n\nhttp://cprogramming.com/discussionarticles/sorting_and_searching.html
60448
To use pointer with 2D matrix it is better to use pointer to a pointer. It can be used like usual 2D array.\nCode in main should be something like below\n//input dimension from user, m by n matrix\nint** matrix;\nmatrix=new int*[m];\nfor( i=0;i<m;i++)\nmatrix[i]=new int[n];\n// now input matrix from user in usual way.\n\nnow you can use this pointer to pointer as usual 2D array, when calling function just pass pointer to pointer as argument.\nI have said you how to raotate 2D array in your previous question. I'm just repeating procedures, not the code.\nFirst transpose the matrix and then reflect it wrt horizontal axis. I think this will work.
1006176
Generating a Pseudo-Random Number Sequence\n\n#include <stdio.h>\n#include <stdlib.h>\n...\n    long count, i;\n    char *keystr;\n    int elementlen, len;\n    char c;\n...\n/* Initial random number generator. */\n    srand(1);\n\n    /* Create keys using only lowercase characters */\n    len = 0;\n    for (i=0; i<count; i++) {\n        while (len < elementlen) {\n            c = (char) (rand() % 128);\n            if (islower(c))\n                keystr[len++] = c;\n        }\n\n        keystr[len] = '&#92;0';\n        printf("%s Element%0*ld&#92;n", keystr, elementlen, i);\n        len = 0;\n    }\n\n\nGenerating the Same Sequence on Different Machines\n\nstatic unsigned long next = 1;\nint myrand(void)  /* RAND_MAX assumed to be 32767. */\n{\n    next = next * 1103515245 + 12345;\n    return((unsigned)(next/65536) % 32768);\n}\n\nvoid mysrand(unsigned seed)\n{\n    next = seed;\n}\n\n\nRATIONALE\n\nThe ISO C standard rand() and srand() functions allow per-process pseudo-random streams shared by all threads. Those two functions need not change, but there has to be mutual-exclusion that prevents interference between two threads concurrently accessing the random number generator.\n\nWith regard to rand(), there are two different behaviors that may be wanted in a multi-threaded program:\n\nA single per-process sequence of pseudo-random numbers that is shared by all threads that call rand()\n\nA different sequence of pseudo-random numbers for each thread that calls rand()\n\nThis is provided by the modified thread-safe function based on whether the seed value is global to the entire process or local to each thread.\n\nThis does not address the known deficiencies of the rand() function implementations, which have been approached by maintaining more state. In effect, this specifies new thread-safe forms of a deficient function.
1047890
class C\n{\npublic:\nenum { NUM_VALUES = 10 };\n\nprivate:\ndouble m_values[NUM_VALUES];\n\npublic:\n// Sets the number stored at index i in m_values to v\nvoid SetValue(int i, double v) throw( std::exception )\n{\nif ( i < 0 || i >= NUM_VALUES ) throw std::exception("Index out of range");\nm_values[i] = v;\n}\n\n// Gets the number stored at index i in m_values\ndouble GetValue(int i) const throw( std::exception )\n{\nif ( i < 0 || i >= NUM_VALUES ) throw std::exception("Index out of range");\nreturn m_values[i];\n}\n\n    // Returns the mean of the numbers stored in m_values\n    double GetMean(void) const \n    {\n        double sum = 0;\n        for ( int i = 0; i < NUM_VALUES; i ++ ) sum += m_values[i];\n        return sum / NUM_VALUES;\n    }\n\n    // Returns the sample standard deviation of the numbers stored in m_values\n    double GetStandardDeviation(void) const \n    {\n        double mean = GetMean();\n        double sum = 0;\n        for ( int i = 0; i < NUM_VALUES; i ++ ) sum += (m_values[i]-mean)*(m_values[i]-mean);\n        return sqrt(sum/(NUM_VALUES-1));\n    }\n};
785470
There are numerous ways to do that. \nHere is, probably the simplest:\n\nchar *s="char *s=%c%s%c;%cmain() {printf(s,34,s,34,10,10);}%c";\nmain() {printf(s,34,s,34,10,10);}\n\nThe program itself is fairly useless.\nThe whole point of an exercise like this is the satisfaction of finding a solution yourself. Too bad, you did not give yourself a chance
345978
/* Here's the entire code [including the main() function]. I have written a generic reverse function which can be used anywhere. */\n\n#include <stdio.h>\n\nvoid reverse ( char str[] )\n{\n        char *ptr = str;\n        int arrLength = strlen( str );\n        int i;\n        char temp[arrLength];\n\n        for ( i = (arrLength-1); i >= 0; i-- )\n        {\n                temp[i] = *ptr++;\n        }\n\n        ptr = str;\n\n        for( i = 0; i < arrLength; i++ )\n        {\n                *ptr++ = temp[i];\n        }\n\n\n}\n\nint main()\n{\n        char str[] = "This will be reversed";\n        reverse( str );\n        printf( "%s", str);\n\n}
1108238
I can provide you complete programs of data structures (linked list, array handling, stacks, queues, tress, graphs, and other algorithms). for this you have to provide me your information and details for what purpose you have to use this? and what your are doing currently. you can communicate me on my email address. abhi_patni@yahoo.com.
389147
PEEK read a 8bit value from any memory address\ninteger_variable = PEEK(address)\n\nPOKE write a 8bit value to a memory address (not all addresses may be written!)\nPOKE address, value
709447
Declare a two dimensional pointer for example :\n\nint **x;\n\nx = static_cast<int **>(malloc(sizeof(void *) * dimension x));\nfor ( i = 0; i<dimension x; i++)\n{ \n   x[i] = static_cast<int**>(malloc(sizeof(void) * dimension y));\n}\n\nYou are ready to use x[i][j]
359046
#include <ctype.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic char *article[] = { "the","a", "one", "some", "any" };\nstatic char *noun   [] = { "boy","girl", "dog", "town", "car" };\nstatic char *verb   [] = { "drove","jumped", "ran", "walked", "skipped" };\nstatic char *prep   [] = { "to", "from", "over", "under", "on" };\n\nint\nmain()\n{\n  int asize = sizeof(article)/sizeof(article[0]);\n  int nsize = sizeof(noun)/sizeof(noun[0]);\n  int vsize = sizeof(verb)/sizeof(verb[0]);\n  int psize = sizeof(prep)/sizeof(prep[0]);\n\n  char buff[100];\n  for (int i=0; i<20; i++) {\n    (void)sprintf(buff, "%s %s %s %s %s %s.",\n      article[rand()%asize],\n      noun[rand()%nsize],\n      verb[rand()%vsize],\n      prep[rand()%psize],\n      article[rand()%asize],\n      noun[rand()%nsize]);\n    *buff = toupper(*buff);\n    (void)printf("%s&#92;n", buff);\n  }\n  return 0;\n}\n\n\n$ a.out\nSome town walked to a dog.\nThe car ran from any dog.\nAny boy drove under any town.\nOne girl jumped under the girl.\nOne car jumped to one girl.\nAny boy skipped over a dog.\nAny town jumped from some town.\nThe town ran from the town.\nOne car walked to any town.\nOne town ran over one boy.\nAny town jumped on the car.\nSome dog skipped from a boy.\nSome girl skipped over a boy.\nA car walked over some girl.\nThe car jumped from a girl.\nThe boy skipped on the town.\nAny car walked from one girl.\nAny dog ran to a town.\nA car jumped under some car.\nSome boy walked to the car.