Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int** converCharArrayToInt(char * text,int N_Row,int N_Columns){
- int ** res = (int**)malloc(sizeof(int*)*N_Row);
- for (int i = 0; i<N_Row;i++){
- int * temp = (int*)malloc(sizeof(int)*N_Columns);
- for (int j = 0; j<N_Columns;j++){
- printf("%d %d %d\n",i*N_Columns,j,text[i*N_Columns+j]);
- temp[j] = (int) text[i*N_Columns+j];
- }
- res[i] = temp;
- }
- return res;
- }
- int main()
- {
- char* st = "123456789123456789";
- int** res = converCharArrayToInt(st ,9,strlen(st)/9);
- for (int i = 0; i<9;i++){
- printf("[ ");
- for (int j = 0; j<2;j++){
- printf("%d,",res[i][j]);
- }
- printf("]\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement