Search:

Type: Posts; User: ronin

Page 1 of 14 1 2 3 4

Search: Search took 0.02 seconds; generated 18 minute(s) ago.

  1. In the Homework function, at least, you've...

    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...
  2. I find this topic fascinating. :) I didn't have...

    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...
  3. Thread: C Beginning

    by ronin
    Replies
    3
    Views
    1,149

    I'd use fgets. if val is 10 on k, q, or j, then...

    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 ......
  4. I'd create a struct for the falling block, and...

    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...
  5. In the movement function, at least, you're off by...

    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++)
    ...
  6. Replies
    5
    Views
    1,097

    you should check that your file is open before...

    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
  7. Replies
    5
    Views
    1,097

    The first failed because you're trying to...

    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] =
    {
    { '*', '*', '*', '*',...
  8. Glad you were able to get what you needed. :) I...

    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...
  9. what is you're wanting to print exactly? A...

    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
  10. Replies
    2
    Views
    7,786

    if you mean print the contents of your 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...
  11. Replies
    7
    Views
    971

    The if statement had nothing to do with the...

    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...
  12. Replies
    7
    Views
    971

    It might be a good idea to check the return value...

    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...
  13. Replies
    4
    Views
    991

    The struct declaration doesn't look like - you're...

    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...
  14. Replies
    5
    Views
    1,595

    If you don't mind a basic vertical graph, then...

    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...
  15. Replies
    8
    Views
    1,192

    loop while your input is greater than zero. ...

    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...
  16. Replies
    8
    Views
    1,192

    I'd try a char array for input. In the loop...

    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;
  17. Replies
    5
    Views
    1,290

    Thanks c99; it's been a long time since I've...

    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. :)
  18. Replies
    4
    Views
    2,926

    strcpy(listOfWords[randomChoice],...

    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...
  19. Replies
    5
    Views
    1,290

    Don't use it myself, but couldn't something like...

    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 =...
  20. Replies
    12
    Views
    1,203

    I declared three variables in main and passed...

    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...
  21. Replies
    12
    Views
    1,203

    you can pass them in as parameters. void...

    you can pass them in as parameters.



    void a2question2(float *n1, float *n2, float *n3)
    {
    int i;

    for(i=1; i <= 3; ++i)
    {
  22. Replies
    12
    Views
    1,203

    if you're getting compiler errors with that code,...

    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.
  23. Replies
    12
    Views
    1,203

    I'd imagine anything is possible with a bit of...

    I'd imagine anything is possible with a bit of effort.



    #include <stdio.h>

    int main(void)
    {
    // declare variables
    // show prompt(s)
  24. Thread: strcmp

    by ronin
    Replies
    10
    Views
    1,236

    if you mean that you don't want to display "no...

    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.

    ...
  25. Replies
    11
    Views
    3,873

    int size=6; int minimum, b, c, location = 1;...

    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...
Results 1 to 25 of 350
Page 1 of 14 1 2 3 4