In the Homework function, at least, you've prototyped it to take a double as an argument and return a double. When you call the function in main, you're passing in an uninitialized copy and not...
Type: Posts; User: ronin
In the Homework function, at least, you've prototyped it to take a double as an argument and return a double. When you call the function in main, you're passing in an uninitialized copy and not...
I find this topic fascinating. :) I didn't have time to test it very much, but I was thinking along the lines of below for dropping blocks. I'm in a bit of a rush, so please excuse the formatting...
I'd use fgets. if val is 10 on k, q, or j, then you could use
if(toupper(card_name[0]) == 'K' || toupper(card_name[0]) == 'Q' || toupper(card_name[0]) == 'J')
val = 10;
else if ......
I'd create a struct for the falling block, and rather than some random block pattern, maybe a few specific patterns - cube, line, angle, etc
typedef struct
{
int shape; // current block...
In the movement function, at least, you're off by at least 1 in your loops. You've got block box[ROW][COLUMN], but then you hard code boundaries for some reason.
for (rw=0;rw<16;rw++)
...
you should check that your file is open before you try and read/write to it.
if(outputFile.is_open())
{
...
}
I don't use cpp often, but I got an output file using
The first failed because you're trying to initialize a 2d array of chars by stuffing more than a single character into an index position.
char test[5][5] =
{
{ '*', '*', '*', '*',...
Glad you were able to get what you needed. :) I approached it along the lines of
for(r = -1; r <= ROW; ++r)
{
for(c = -1; c <= COLUMN; ++c)
{
if(r == -1 || r == ROW || c...
what is you're wanting to print exactly? A border separate from the contents of the array?
void disp_box(char b[ROW][COLUMN])
{
int r, c;
// add border around contents of 2d array
if you mean print the contents of your array within the function, then where you've got printf("_ ") you can either use
putchar(b[r][c]);
// or
printf("%c", b[r][c]);
if you mean add...
The if statement had nothing to do with the digits, but whether or not the input received from the user was valid for the data type being used. scanf returns an integer that represents how many...
It might be a good idea to check the return value of scanf before trying to process the input. Since number is not initialized, the user could enter a non-digit yet the loop may run giving a result...
The struct declaration doesn't look like - you're missing the semi-colon at the closing brace.
products inventory[5] is local to main; the initProducts function doesn't have access to it. Either...
If you don't mind a basic vertical graph, then you could create two loops - an outer loop controlled by the length of data and an inner loop controlled by data's value at each iteration for printing...
loop while your input is greater than zero. Check into the modulus operator for finding the digit, compare that value against the target number for counting, and lastly use division on the input to...
I'd try a char array for input. In the loop body, test for the desired number and increment a count variable.
if char_arr[loop_index] equals some_digit
// increment count;
Thanks c99; it's been a long time since I've tried that method, and wasn't sure if I had it right. I'd go with the struct too, but pass it as a parameter. :)
strcpy(listOfWords[randomChoice], selectedWord[numOfWords]);
in the function SelectWord, you're asking strcpy to treat selectedWord as though it were an element within an array of strings. If...
Don't use it myself, but couldn't something like below be used or have I forgotten how the mechanism works? I'm curious.
float* xxxx(float a, float b, float c, float d)
{
float *tmp =...
I declared three variables in main and passed them by reference to a2question2 so that they could be modified within that function via scanf; I used the ? operator like an if/else if/else or switch...
you can pass them in as parameters.
void a2question2(float *n1, float *n2, float *n3)
{
int i;
for(i=1; i <= 3; ++i)
{
if you're getting compiler errors with that code, get rid of the non-standard parts #include<conio.h>, clrscr(), and getch(). Get rid of void main regardless.
I'd imagine anything is possible with a bit of effort.
#include <stdio.h>
int main(void)
{
// declare variables
// show prompt(s)
if you mean that you don't want to display "no records" on each iteration of the file read where strcmp isn't equal, then you could use a variable to flag whether or not a record has been found.
...
int size=6;
int minimum, b, c, location = 1;
for ( c = 0 ; c < size ; c++ )
scanf("%d", &array[b][c]);
Making a habit of using code like above is going to burn you if...