프로그래밍 및 시각적 인 스튜디오를 처음 사용하고 있습니다. 현재 Visual Studio 2013을 사용하고 있으며, 이후에 디버깅을 시작할 수있는 방법을 알고 싶습니다. 로컬 윈도우 디버거를 시작했습니다. 이 코드에서는 검색 할 숫자를 입력 한 후 디버깅을 시작하려고합니다. 여기 코드가 있습니다.Visual Studio 2013에서 프로그램을 디버깅하는 중 언제든지 실행합니다.
#include<stdio.h`
#include<math.h>
#pragma warning (disable : 4996)
#define MAX_SIZE 100
#define SWAP(x,y,t) ((t) = (x), (x) = (y), (y) = (t))
int size_check(int n)
{
int a;
a = n;
if (a < 1 || a>100)
{
(a < 1) ? printf("\nSize can't be smaller than 1 , please try again!") : printf("\nmax size allowed is 100, pleasetry again");
printf("\nEnter the length of array :\t ");
scanf("%d", &a);
return(size_check(a)); /*or a = size_check(a)*/
}
return a;
}
void sort_array(int list[], int n)
{
int i, j, temp;
for (i = 0; i < n - 1; i++)
for (j = i + 1; j < n;j++)
if (list[i]>list[j])
{
SWAP(list[i], list[j], temp);
}
}
void b_search(int list[], int sno,int a)
{
int left, right, middle, i=1, n=a-1;
left = 0;
right = n;
while (left != right)
{
middle =((left + right)/2);
if (sno == list[middle])
{
printf("\nSearched number is present in array at %d ",middle);
break;
}
if (sno < list[middle])
{
right = middle - 1;
}
else
{
left = middle + 1;
}
}
if (left == right || sno != list[middle])
printf("Searched number is not present in array!");
}
void main()
{
int n, i ,sno,list[MAX_SIZE];
printf("Enter the length of array :\t ");
scanf("%d", &n);
n=size_check(n);
for (i = 0; i < n; i++)
{
printf("Enter the %d element of array:\t",i);
scanf("%d", &list[i]);
}
sort_array(list, n);
printf("\nThe shorted array :");
for (i = 0; i < n; i++)
{
printf("\n%d",list[i]);
}
printf("\nEnter the number you want to search in array:\t");
scanf("%d", &sno);
b_search(list, sno, n);
getch();
}