Problem running program

This is a discussion on Problem running program within the C++ Programming forums, part of the General Programming Boards category; Hi, When I run programs in MS-2 and I try to input data (in scanf functions) I get dwwin.exe error ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    52

    Problem running program

    Hi,
    When I run programs in MS-2 and I try to input data (in scanf functions) I get dwwin.exe error and program stops.
    It happens in all programs I've created in C++ with Microsoft Visual Studio 6.0 everytime I try to input data (I've not other compilers).
    I use Windows XP Professional Service Pack 2.
    The problem appeared suddenly a few weeks ago.
    So, what is really happen? How to solve it?
    Thank you

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    any example code?

    what is MS-2?

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    52
    I'm sorry it is MS-DOS
    An example of code, it appears when i run any code with scanf function, for instace this sudoku code:

    Code:
    //sudoku.cpp:
    
    #include<stdlib.h>
    #include<math.h>
    #include<stdio.h>
    #include<time.h>
    #include<algorithm>
    #include<iostream.h>
    
    void main(){
    
    srand(time(0));
    
        int a1;
        int b1;
        int c1;
        int d1;
        int a2;
        int b2;
        int c2;
        int d2;
            int a3;
        int b3;
        int c3;
        int d3;
            int a4;
        int b4;
        int c4;
        int d4;
            int *ptr_a1;
        int ninc;
            
        srand(time(0));
    d4=0;
    
    while(d4==0)
    {  
    // 1st row
    
    a1=(rand()%4)+1;
    
    printf("a1 = %d\n",a1);
    
    do {
        b1=(rand()%4)+1;
    }while(b1==a1);
    {
    printf("b1 = %d\n",b1);
    }
    
    do {
        c1=(rand()%4)+1;
    }while((c1==a1)||(c1==b1));
    {
    printf("c1 = %d\n",c1);
    }
    
    do {
        d1=(rand()%4)+1;
    }while((d1==a1)||(d1==b1)||(d1==c1));
    {
    printf("d1 = %d\n",d1);
    }
    
    // Column A
    do {
        a2=(rand()%4)+1;
    }while((a2==a1)||(a2==b1));
    {
    printf("a2 = %d\n",a2);
    }
    
    do {
        a3=(rand()%4)+1;
    }while((a3==a1)||(a3==a2));
    {
    printf("a3 = %d\n",a3);
    }
    
    do {
        a4=(rand()%4)+1;
    }while((a4==a1)||(a4==a2)||(a4==a3));
    {
    printf("a4 = %d\n",a4);
    }
    
    // Column D
    do {
        d2=(rand()%4)+1;
    }while((d2==c1)||(d2==d1)||(d2==a2));
    {
    printf("d2 = %d\n",d2);
    }
    do {
        d3=(rand()%4)+1;
    }while((d3==d1)||(d3==d2)||(d3==a3));
    {
    printf("d3 = %d\n",d3);
    }
    do {
        d4=(rand()%4)+1;
    }while((d4==d1)||(d4==d2)||(d4==d3)||(d4==a4));
    {
    printf("d4 = %d\n",d4);
    }
    
    // 4th row
    
    do {
        b4=(rand()%4)+1;
    }while((b4==a3)||(b4==a4)||(b4==b1)||(b4==d4));
    {
    printf("b4 = %d\n",b4);
    }
    
    do {
        c4=(rand()%4)+1;
    }while((c4==d3)||(c4==d4)||(c4==c1)||(c4==a4)||(c4==b4));
    {
    printf("c4 = %d\n",c4);
    }
    
    // Central square
    
    do {
        b2=(rand()%4)+1;
    }while((b2==a1)||(b2==b1)||(b2==a2)||(b2==d2)||(b2==b4));
    {
    printf("b2 = %d\n",b2);
    }
    
    do {
        c2=(rand()%4)+1;
    }while((c2==c1)||(c2==d1)||(c2==a2)||(c2==b2)||(c2==d2)||(c2==c4));
    {
    printf("c2 = %d\n",c2);
    }
    
    do {
        b3=(rand()%4)+1;
    }while((b3==a3)||(b3==a4)||(b3==b4)||(b3==b1)||(b3==b2)||(b3==d3));
    {
    printf("b3 = %d\n",b3);
    }
    
    do {
        c3=(rand()%4)+1;
    }while((c3==c4)||(c3==d4)||(c3==d3)||(c3==c1)||(c3==c2)||(c3==a3)||(c3==b3));
    {
    printf("c3 = %d\n",c3);
    }
    if (b4!=0)
       {
         break;
       }
    }
    
    // Program shows all the sudoku
    
    cout <<""<<endl;
    cout <<"Sudoku"<<endl;
    
    cout <<a1<<" "<<b1<<" "<<c1<<" "<<d1<<endl;
    cout <<a2<<" "<<b2<<" "<<c2<<" "<<d2<<endl;
    cout <<a3<<" "<<b3<<" "<<c3<<" "<<d3<<endl;
    cout <<a4<<" "<<b4<<" "<<c4<<" "<<d4<<endl;
    
    cout <<""<<endl;
    
    // The program choose and erase a number of items determinated by the user
    
    printf("Enter how many items do you want to erase, please\n");
    scanf("%s",ninc);

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    vs6 uses windows, not dos. do you mean a dos box?
    Code:
    #include<stdlib.h>
    #include<math.h>
    #include<stdio.h>
    #include<time.h>
    use <cheader> instead of <header.h> for C in C++.
    Code:
    #include<iostream> /* no .h */
    
    void main(){
    http://faq.cprogramming.com/cgi-bin/...&id=1043284376
    Code:
    srand(time(0));
    
    ...
    why twice?
            
        srand(time(0));

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [NEED HELP] I just can't solve this program problem!
    By frodonet in forum C Programming
    Replies: 7
    Last Post: 09-23-2007, 02:44 PM
  2. How to tell when internal program is done running
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 03-21-2005, 09:09 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. Problem running program in Win98
    By GaPe in forum C Programming
    Replies: 1
    Last Post: 10-19-2003, 12:08 PM
  5. Problem with Program not Quitting
    By Unregistered in forum Windows Programming
    Replies: 20
    Last Post: 06-11-2002, 11:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21