Run-Time Check Failure #2 - Stack around the variable 'nJ' was corrupted

please help me..
whenever i run the program,it always shows "Run-Time Check Failure #2 - Stack around the variable 'nJ' was corrupted"

i had no ideas why this happened.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  #define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	char szName[20],szMaterial[30];

	double dL ,dDu, dDi, dWid, dAusd, dTmin, dTmax, dSpan, dStr, dr, dL1, dL2, dL3, dA, dR;

	unsigned short nX, nY, nZ, nD, nM, nJ;

	printf("\n\n");
	printf("%45s \n\n\n","Dateneingabe");

	printf("Sacharbeiter                  : ");
	scanf("%s",&szName);

	printf("Erstelldatum                  :");
	scanf("%d.%d.%d",&nD,&nM,&nJ);
It'd help if we could get the full code, especially since it's a run-time error.
%d expects pointer to integer, and you are diving pointers to short, which may be smaller than integer.

Use %hd instead

http://en.cppreference.com/w/c/io/fscanf
thank you very much MiiNiPaa!!
it's work!! Great!!
Last edited on
Topic archived. No new replies allowed.