where does const variable in c code in memory reside?
460852
It sits in the heap that is allocated to your program by the OS.  It doesn't reside anywhere special, it is just marked read only.  There are ways around that if you really try.
257370
There are a number places in the C++ spec that say that the method of implementation is left up to the designer of the compiler as long as they meet certain requirement.\n\nFor example, the rules require that the storage size of a long be at least as large as that for an int.\nMicrosoft C++ makes both ints and longs 32 bits. A program that works with 32 bit longs could very easily fail with 16 bit longs and vice versa. \n\nIt's also possible that you are breaking a rule that you can get away with on with one compiler, but not the other. For example, if you are running a program built with MS C++ using debug heap allocation, when you free the memory, it gets overwritten with a specific pattern to aid in debugging. If you use a stale pointer, you'll be pointing to trash. The same code built using another compiler might still find valid values in the memory, even though you released it.
477862
I can see by looking at it that it won't compile.\nYou don't have semicolons at the end of the lines.\n\nI you put in the semicolons and replace the comma in the for loop with the another semicolon, it will compile and run.\n\nHowever, I don't think that you will get what you expect.\n\nYou use x without initializing it. That means that x will take the value that is already in memeory at that address.\n\nNext you condition your while loop on (R!=R) which is always false, so the while loop never executes.\n\nWhat you will print out is the last value that was left in x which is a location on the stack. \nI'm running MS C++ in debug mode, so it fills in the bytes of x with the value CC so you can recognize it as uninitialized stack memory.\n\nLast, you compute S but never use it.
295277
#include <iostream.h>\n#include <string.h>\n\nstruct String\n{\npublic:\nchar * Data;\nint Length;\n};\nString operator+(const String & s1,const String & s2)\n{\nchar * s3=new char [s1.Length+s2.Length];\nstrcpy(s3,s1.Data);\nstrcat(s3,s2.Data);\n\nString Out;\nOut.Data=s3;\nOut.Length=s1.Length+s2.Length;\nreturn Out;\n}\n\n//you can't directly overload char * because at least one operand of any overloaded operator must be of some user-defined type.\n\n//u can use strcat
169151
int\nmain (void)\n{\nfor(i=0;i<10;i++){\nprintf("some thing output here %d", i)\n}\n}
1008551
Not sure the question but it is set up (generally) as a program that has includes (one for data declarations, one for the main program, one to hold the subroutines). The main can then reference the includes decreasing impact issues when changes are required.
374089
It has 2-bytes code, so you need to examine two consequent bytes. It is not C++ specific, it is PC-specific.
687702
A previous answer explained that "array subscripts get\ncompiled down to use pointer arithmetic".\n\nIt's not simply an implementation issue, but rather a\nlanguage definition issue.  Section 6.3.2.1 of the Ansi C\nstandard explains that except when used as the argument of\na "sizeof" or "&" operator, a reference of "array of type"\nis converted to reference of "pointer to type" which\npoints to the initial element of the array.\n\nTo use the example from the previous poster, "x[i]" is\n_defined_ to be *(x+i).\n\nTo extend the illustration (and to confuse your friends),\nconsider the following.  A character string reference is\nconverted to type "pointer to char", but since pointers\ncan be used in array context, you can reference one as\nfollows:\n\n    char c = "house"[3];\n\nBut as the other poster explained, since x[5] is \nsemantically equivalent to 5[x], the following is\nalso legal:\n\n\n    char c = 3["house"];\n\nThis, of course, equals the character value 's'.\n\n\nFinally, for those answering who are so young that \nthey think "C is the mother of all languages", you \nmight do a quick web search on the words "Fortran" \nand "Algol" :-)
334651
If you use an array, then use the mod operator to choose the first element of the array to access the array once you have passed the last element of the array. \n\ni = 0; \nwhile (1)\n{\n   printf ("%d", a[i%n]); // 'n' is the size of the array\n   i++;\n}
600562
Okay once again..\nStringBuffer b = buf.replace(6,10,"orld");\n\nThis replaces offset 6 to 10 with world... So offset 6 in your case is W so it would be:\nHello orld\n\nNow That is correct.. Now b.delete(0, 1)\nThat deletes the 0 offset which is H! only so it would be\nello\n\nNow the total StringBuffer Contents is:\nello orld\n\n\nSee why? Remember buffers is like a memory location that stores a buffer, so treat it as global scope in that case
24430
It's a memory leak.  A type of bug.  When the program uses a section of memory, it never gives it up when its done - so eventually it expands to include all of your usable space.\n\nFile a bug complaint and wait for a patch.
800867
Here you go:\nhttp://en.wikipedia.org/wiki/Malloc\n\n///
326706
var\nP : Array[0..10,11..20] of Pointer;
973633
could cause programs to look in the wrong place for things. change it to c
550757
I have heard this question so many times that I decided to look it up on the net and I found a very good site that explains it very well, step by step.\nSo I will simply link that one here. This is the C equivalent, you can modify it for c++!\n\nhttp://www.iwebthereforeiam.com/programming/selfWrite.asp\n\nEnjoy!
958875
"register" declares a variable to be stored in a CPU register rather than RAM.\n\nIt is a hangover from the olden days when the memory CPU bus interface was slow by todays standards. It allowed for faster execution by storing a variable directly into a CPU register instead of RAM eliminating the data fetch execute cycle associated with decoding the address of the data and moving the data in and out of a CPU  register.\n\nThis type is more or less defunct in modern C programming. One of the mostly widely used compilers Microsofts Visual C++ no longer implements this, although it still supports the declaration for backward compatibility. \n\nIn fact when it sees a register variable it just converts it into a normal variable store in RAM. In MS Visual C++ you can even use & on a register variable to get its address which you shouldn't be able to do in ANSI C as an internal CPU register has no address! \n\nModern compilers like Visual C++  automatically use CPU registers if the relevant optimisation is turned on in the compiler flags. Therfore there is no longer any requirements for the programmer to implement low level optimisation using register variables. You could use any alternate data type that suits your needs. e.g. (short) int, long
423103
#include <stdio.h>\n#include <stdlib.h>\n\nint\nmain(int argc, char* argv[])\n{\n  int count = argc>1 ? atoi(argv[1]) : 10;\n  FILE *f = fopen("numfile", "w+");\n  if (!f)\n    perror("fopen"), exit(-1);\n  for (int i=0; i<count; i++)\n    fprintf(f, "%d&#92;n", rand());\n  fclose(f);\n  return 0;\n}