A
AndersMaj
Guest
hello
i am writing a very simple C++ program to test random number recall but the code compiles and runs it just doesn't seem to work terribly well... have a look at this code:
// chunking.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int i, j, num;
char s[80], s2[80];
while (1) {
num = 0;
for (i = 0; i < 10; i++) {
j = (rand() * 10) / RAND_MAX;
if (j == 10) --j;
s = j+'0';
}
s = 0;
printf("%s", s);
getchar();
for (j = 0; j < 100; j++)
printf("\n");
printf("Enter number: ");
scanf_s("%79s", s2);
if (!strcmp(s, s2))
printf("Incorrect!\n");
else
printf("Correct!\n");
getchar();
}
}
hope you can help!
Continue reading...
i am writing a very simple C++ program to test random number recall but the code compiles and runs it just doesn't seem to work terribly well... have a look at this code:
// chunking.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int i, j, num;
char s[80], s2[80];
while (1) {
num = 0;
for (i = 0; i < 10; i++) {
j = (rand() * 10) / RAND_MAX;
if (j == 10) --j;
s = j+'0';
}
s = 0;
printf("%s", s);
getchar();
for (j = 0; j < 100; j++)
printf("\n");
printf("Enter number: ");
scanf_s("%79s", s2);
if (!strcmp(s, s2))
printf("Incorrect!\n");
else
printf("Correct!\n");
getchar();
}
}
hope you can help!
Continue reading...