ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!

Jump to content



Photo

How to make a program restart from beginning


  • Please log in to reply
How to make a program restart from beginning

#1

diefolain
diefolain
    Offline
    -2
    Rep
    0
    Likes

    Advanced Member

  • PipPipPipPip
Posts: 75
Threads: 7
Joined: Jun 08, 2018
Credits: 0
Five years registered
#1

#include <iostream>
#include <stdlib.h>     //pentru fct rand
#include <time.h>
#include <ctime>
#include <conio.h>

using namespace std;

int main()

{
    getch();
    unsigned int a[5][5],j,i,cr,b;
        srand(time(NULL));
    for( i = 0; i < 5; ++i)
  {for( j = 0;  j < 5; ++j)
    a[i][j]=rand()%5;
  }
  for( i = 0; i < 5; ++i)
  {for( j = 0; j < 5; ++j)
     cout<<a[i][j]<<" ";
   cout<<'\n';
  }
if (getch())// after this i want to return to the first expression any idea on how? only if (getch()) tho

}


  • 0

#2

n3n3
n3n3
    Offline
    168
    Rep
    1650
    Likes

    so edgy i'm a hectogon

Posts: 517
Threads: 31
Joined: Mar 22, 2015
Credits: 0

Eight years registered
#2

You are mixing up C headers and C++...

 

just wrap your main body in a

char c;
while (cin >> c)
{
..
}

  • 0

:joduscry: ?url=https%3A%2F%2Fi.imgur.com%2FLtzFqjc :joduscry:

unknown.png



 Users browsing this thread: