Created
June 28, 2016 01:02
-
-
Save JuanCrg90/fdbc1bccf2202c61c964596b904b76a5 to your computer and use it in GitHub Desktop.
A Simple C-Lang Pointers Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main () { | |
typedef struct complex_tag { | |
float r; | |
float i; | |
} complex; | |
int tam; | |
int i; | |
complex *nums; | |
scanf("%d", &tam); | |
nums = (complex*) malloc( sizeof(complex) * tam ); | |
for( i = 0; i < tam; i++ ) { | |
nums[i].r = i; | |
nums[i].i = i*2; | |
} | |
for( i = 0; i < tam; i++ ) { | |
printf("r: %f, i: %f \n ", nums[i].r, nums[i].i); | |
} | |
free(nums); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment