Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int** converCharArrayToInt(char * text,int N_Row,int N_Columns){
  6. int ** res = (int**)malloc(sizeof(int*)*N_Row);
  7.  
  8. for (int i = 0; i<N_Row;i++){
  9. int * temp = (int*)malloc(sizeof(int)*N_Columns);
  10. for (int j = 0; j<N_Columns;j++){
  11. printf("%d %d %d\n",i*N_Columns,j,text[i*N_Columns+j]);
  12. temp[j] = (int) text[i*N_Columns+j];
  13. }
  14. res[i] = temp;
  15. }
  16. return res;
  17. }
  18. int main()
  19. {
  20. char* st = "123456789123456789";
  21. int** res = converCharArrayToInt(st ,9,strlen(st)/9);
  22. for (int i = 0; i<9;i++){
  23. printf("[ ");
  24. for (int j = 0; j<2;j++){
  25. printf("%d,",res[i][j]);
  26. }
  27. printf("]\n");
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement