Basically, your code needs to generate a vertical sine wave in ascii art?
Please use code tags to make your code more readable.
I do see some mistakes already:
1 2 3
|
while (angle = PIx2);
{
// etc...
|
Do not write a semicolon after the while line, or it'll disconnect the while statement from the block of code that makes up your loop.
(angle = PIx2), note that you're using only one =, so this is an assignment, not a comparison. Use == instead. Also, are you shure you didn't mean a less-than or greater-than comparison? (<, <=, >, >=)
If you correct those, does it work?
Also, your constants use a "," as the decimal seperator. Use a "." instead.
Your program then becomes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <math.h> // ANSI function prototypes
#include <stdio.h> // Prototype of 'printf' function
#include <stdlib.h> // Prototype of 'system' & 'exit' functions
/************************************************
* 1.- SYMBOL DEFINITIONS *
************************************************/
#define PIx2 6.283 // 2 . PI
#define DELTA 0.300 // Increment step
/************************************************
* 2.- NEW DATA TYPES *
************************************************/
typedef enum {
ERROR = -1,
OK
} Ret_cod_t;
/************************************************
* 3.- FUNCTION PROTOTYPES *
************************************************/
int main (void);
void Print_Stars (int nos);
/***************** main *********
* Shows a sinusoid wave in the screen. *
************************************************/
int main (void)
{
double number_of_stars, angle = 0;
while (angle < PIx2)
{
number_of_stars = 40.f + 30.f * sin (angle);
Print_Stars ((int) number_of_stars); // print line with stars
angle += DELTA;
}
return 0;
}
/************ Print_Stars *********
* *
* Prints a line of 'nos' asterisks. *
* *
* Input: int nos (number of stars-asterisks *
* Output: nothing *
* *
************************************************/
void Print_Stars (int nos)
{
int i = 0;
while (i < nos)
{
printf ("*");
i++;
}
printf ("\n");
}
|