Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* In order to compile this on my linux system
- * even though the instructions were given like this
- * $ gcc sine_print.c -o sine_print
- * I had to add -lm or it will return exception
- * sine_print.c:(.text+0x8c): undefined reference to `sin'
- * collect2: ld returned 1 exit status
- * for some reason it wouldn't link the math.h at the compile step
- * So I typed $ gcc sine_print.c -lm -o sine_print
- * latter I saw a post with a similar problem and they typed
- * $ gcc -Wall foo.c -o foo -lm
- * I'm not sure if the syntax is a convention but the first way
- * worked for me. -Wall I have seen when compiling stuff in Linux but need to
- * look at the manpage still so check out those flags before you type it
- * Also another weird thing is when I typed
- * gcc sine_print.c -o sine_print.c
- * the file disappeared completely from my computer
- * is this a bug or normal behavior? IDK
- * prints a sideways sine wave in ASCII chars
- */
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- int main()
- {
- int i;
- int offset;
- char sinstr[80];
- memset(sinstr,0x20, 80);
- sinstr[79] = '\0';
- for (i = 0; i < 20; i++) {
- offset = 39 + (int)(39 * sin(M_PI * (float) i/10)):
- sinstr[offset] = '*';
- printf("%s\n", sinstr);
- sinstr[offset] = ' ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement