What is the right way to write and debug a program?

I am preparing for DSA, and I find it difficult to debug arrays inside a function. When I enter the function in the debugger, I can only see the starting address and the value of the first array element. I am not able to see the other array values. What is the right way to debug this, and how should I write the program to make debugging easier?

This is sort01 code fro example:

debugging image : [debug.png](https://postimg.cc/JGfZ8jrd)

#include <stdio.h>
#include <stdlib.h>

void sort01(int *array, int n)
{
    int tmp=0;
    int left=0;
    int right=n-1;
    while(left <= right)
    {
        if(array[left] !=0)
        {
tmp = array[left];
array[left]= array[right];
array[right]=tmp;
right--;
        }
        else
        {
            left++;
        }
    }
}
int main()
{
int array[]={1,0,1,1,1,0,0,1,0};
int n=sizeof(array)/sizeof(array[0]);
sort01(array, n);
for( int i=0 ;i<n ; i++)
printf( "%d",array[i]);
return 0;
}
u/sudheerpaaniyur — 8 days ago

This social media influencer crying and making money

Yesterday i have seen some channel views 3 lakh for 6 hours, content is crying and one guy his bmw got accident and in comments section people giving suggestions like they're his family.

Influencer and crying and people fall for this.

I was felt bad for our older generation watching daily soap and astrology , now younger falling for this social media influencer.

reddit.com
u/sudheerpaaniyur — 8 days ago
▲ 2 r/Udupi

Ajarkadu ground running track allowed for public ?

Please let me know, this ajjarakadu ground running trakc allowed for public?

reddit.com
u/sudheerpaaniyur — 9 days ago
▲ 19 r/Udupi

Free run marathon manipal

Completed 3k, it was raining and felt good.
Felt good, hope you guy attended.

u/sudheerpaaniyur — 11 days ago
▲ 4 r/EmuDev

is it possible to emulate spi in qemu?

i am just started learning qemu and able to simulate UART, now i want to try spi and i want to read write flash memory.

i have armt cortex mo+ qemu

ps:already any repo i svailable?

reddit.com
u/sudheerpaaniyur — 19 days ago

is it possible to emulate spi in qemu?

i am just started learning qemu and able to simulate UART, now i want to try spi and i want to read write flash memory.

i have armt cortex mo+ qemu

ps:already any repo i svailable?

reddit.com
u/sudheerpaaniyur — 19 days ago

Speed cameras in Udupi highway?

Do we really get a fine if we cross 80kmph in Udupi highways?

Just I'm curious daily i do see people crossing 80 speed

reddit.com
u/sudheerpaaniyur — 20 days ago

Which garmin watch i can buy?

Currently i have amazefit bip6 square dail watch and it broke two times once while swimming and second time while walking in staircase. Both case i hit my hand to rod.

Display cost is 2k.

I'm planning to buy garmin now, my requirements is i have road bike, i do gym, planning to run, frequently i do swim.

My plan is garmin forerunner 165 without music, is it good to go?

Note: i dont have any plans to iron man or trialthon or or any professional tournament.

reddit.com
u/sudheerpaaniyur — 1 month ago

could some one explaina diffrence between call, nested interrupt and contexswitch wr.t to ARM mcu

I am confused about contex switching topic

reddit.com
u/sudheerpaaniyur — 2 months ago

How did you learn your first back flip and front flip

How did you learn your first back flip and front flip into a swimming pool? Beginner looking for advice

I mean diving into the pool

reddit.com
u/sudheerpaaniyur — 3 months ago

Mangalore to Udupi there is many river , what is there original route?

I'm seeing pinakini near pangala and shambavi near mulki just example, undeta moola olpa?

Eranda gottu itunda panle

reddit.com
u/sudheerpaaniyur — 3 months ago

Confused about Queue vs Circular Buffer indexing

In Queue operations (no confusion here):

  1. enqueue -> rear index
  2. dequeue -> front index

But in Circular Buffer, which convention is correct?

Option 1:
push -> head index
pop -> tail index

OR

Option 2:
push -> tail index
pop -> head index

>I see different implementations online, so I'm confused about which index is supposed to be used for write/read operations in a circular buffer.

reddit.com
u/sudheerpaaniyur — 3 months ago

Faced this challenges in my work.

  1. I Delivered Dev SW as A.07 and production SW as B.08, Comparing SW A & B only version got incemented, but Production SW failed and got escallated
    1. its beacuse of B.08 Treated as Octal and its invalid number.
  2. The MCU was resetting in a project with around 10,000 source files. After tracing, we found that the issue was caused by a divide-by-zero error.
reddit.com
u/sudheerpaaniyur — 4 months ago