c - Hadamard matrix code -


i'm trying construct hadamard matrix of dimensions n*n, , print it. code compiles when run it doesn't part asking n input. ideas wrong it?

#include <stdio.h>  void main(void) {  int i, n;  scanf("input n value:   %d", &n);  char **h = (char**) calloc(n, sizeof(char*));  ( = 0; < n; i++ ) {     h[i] = (char*) calloc(n, sizeof(char)); }  int ii, xx, yy;  h[0][0]='1';   for(ii=2; ii<=n; ii*=2) {     //top right quadrant.     for(xx=0; xx<(ii/2); ++xx) {         for(yy=(ii/2); yy<ii; ++yy){             h[xx][yy]=h[xx]yy-(ii/2)];                                   }     }     //bottom left quadrant.     for(yy=0; yy<(ii/2); ++yy) {         for(xx=(ii/2); xx<ii; ++xx) {             h[xx][yy]=h[xx-(ii/2)][yy];         }     }     //bottom right quadrant, inverse of other quadrants.     for(xx=(ii/2); xx<ii; ++xx) {         for(yy=(ii/2); yy<ii; ++yy) {             h[xx][yy]=h[xx-(ii/2)][yy-(ii/2)];             if(h[xx][yy]=='1') {                 h[xx][yy]='0';             }             else {                 h[xx][yy]='1';             }         }     } }   //printing matrix. for(xx=0; xx<n; ++xx) {     for(yy=0; yy<n; ++yy) {         printf("%c",h[xx][yy]);      }     printf("\n"); } } 

scanf doesn't print string, that's used check format of input.

try:

printf("input n value: "); scanf("%d", &n); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -