Your program has undefined behaviour, since you are attempting to access an element of an array, my_strg[length] with an unitialized value of length.
To fix this, move your declaration of length to after the scanf call and initialize it to the length of the string that scanf reads:
scanf("%s", my_strg);
size_t length = strlen(my_strg);
Alternatively, drop the scanf call completely and initialize length to zero:
char my_strg[MAX_SIZE] = { 0, }; // Note: make sure you ALSO initialize your array!!
printf("Please insert the string you want to reverse: ");
size_t length = 0;
while ((temp = getchar()) != '\n') {
//..
Note: If you (for some reason) don't want to initialize your entire array to zeros (as the first line in my second code block will do), then make sure to add a zero (nul) character at the end of the string, before printing it (or doing anything else with it). You could simply add this line after the while loop:
my_strg[length] = '\0'; // "length" will already point to one-beyond-the-end
EDIT: To address the very good points made by David C. Rankin in the comments section, you could (should) improve your while loop control to: (a) prevent buffer overflow and (b) handle input error conditions. Something like this:
while ((length < MAXSIZE - 1) && (temp = getchar()) != '\n' && temp != EOF) {
//..
but the exact tests and controls you use would depend on how you wish to handle such issues.
lengthis uninitialized, somy_strg[length]is likely to be out of bounds.scanfcall left over from an earlier version of the code and you forgot to remove it?int length = 0;, get rid ofscanf("%s", my_strg);(it is superfluous) , change towhile(length < MAX_SIZE - 1 && (temp = getchar()) != '\n' && temp != EOF)addmy_strg[length] = 0;beforeprintf("%s\n", my_strg);to nul-terminate. (or in the alternative initializechar my_strg[MAX_SIZE] = "";)char temp;should be replaced withint temp;because the valueEOFmight not fit in achar.