Answer the question
In order to leave comments, you need to log in
How to store characters in an int array?
Hello!
Here is the code below. How to keep characters in int array after input? Is it possible? Is this correct or do I need to create a 2nd char array?
#include "stdio.h"
int main() {
int i, j, a[9][9], c = 1, n = 5, x = 0;
for (i = 0; i < 9; i++) {
for (j = 0; j < 9; j++) {
a[i][j] = c++;
printf("%0.2d ", a[i][j]);
}
printf("\n");
}
while(n>0) {
printf("Input number: ");
scanf("%d", &x);
for (i = 0; i < 9; i++) {
for (j = 0; j < 9; j++) {
if(a[i][j] == x) {
a[i][j] = 'P';
printf("(%c) ", a[i][j]);
continue;
}
printf("%0.2d ", a[i][j]);
}
printf("\n");
}
n--;
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
one.
the request is executed in 22ms:- I would test a more realistic scenario - how long does XX queries take - eg with https://dev.mysql.com/doc/refman/8.0/en/mysqlslap.html
CentOS, AMD 8 cores (don't remember the model), 64 GB RAM, SSD disks- what is innodb_buffer_pool_size?
set syn_binlog=0 and innodb_flush_log_at_trx_commit=2.
Please report the result.
Look at the connection to the database. Alternatively, connect to it by ip if you connect through the hostname
Have you tried different IO schedulers?
If there is a swap on the server, how many mysql pages are in the swap? Have you tried to test with the swap turned off?
Yes, you can do that, because it char
is also an integer data type. And the variable stores the symbol number in the symbol table. Accordingly, in order to use these values as symbols later, you need to convert them to the char
.
Here is an example:
#include <iostream>
using namespace std;
int main()
{
int i;
char c;
cin >> i;
cin >> c;
cout << i << endl;
cout << c << endl;
i = c;
cout << i << endl;
cout << char(i) << endl;
return 0;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question