Search:

Type: Posts; User: atac

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Replies
    9
    Views
    1,107

    Advantages of using logic vs try/catch?

    This is more of a general coding question I'm curious about. This is a program that determines how many years it would take for a savings account to deplete if you withdraw a certain amount each...
  2. Replies
    9
    Views
    1,005

    I don't think he's gonna have that problem for...

    I don't think he's gonna have that problem for whats he's doing.
  3. Replies
    9
    Views
    1,005

    You should look up documentation on fgets and...

    You should look up documentation on fgets and sscanf, but you could do something like this.



    int getInt(){
    const int STR_SIZE = 20;
    int integer;
    char stringInt[STR_SIZE];
    ...
  4. Replies
    3
    Views
    2,034

    Look at your inner for loop: it doesn't execute...

    Look at your inner for loop:
    it doesn't execute on the first row
    it executes once on the second row *
    it executes twice on the third row **
    it executes three times on the fourth row ***

    Thats...
  5. Replies
    5
    Views
    1,595

    You shouldn't have to change it too much. The...

    You shouldn't have to change it too much. The first one, for example:



    fgets(label[i].name, FNAME, stdin);


    Also refer to fgets - C++ Reference

    Keep in mind, fgets() appends a newline at...
  6. Replies
    5
    Views
    1,595

    I sorted of skimmed through your code but it...

    I sorted of skimmed through your code but it sounds like to need to clear the input buffer after entering an the integer. When you enter an int and hit enter the newline character is skipping the...
  7. Replies
    4
    Views
    690

    Thanks, I accidentally included the code for a...

    Thanks, I accidentally included the code for a user to input the string, but removed it because I wanted to get feedback on the logic of the function instead of the technicals of C.
  8. Replies
    4
    Views
    690

    Critique my trim function

    Just out of the blue I decided to write a trim function, it took me a little while but eventually got it. Can anyone offer some tips on how to optimize it if possible. I feel like theres gotta be...
  9. Replies
    3
    Views
    642

    Question about reading strings from file

    It appears that when you enter command line arguments or use fgets() to input a string you can assign that string to another string variable using the assignment operator. But when you read from a...
  10. Replies
    18
    Views
    3,265

    Alright, in case anyone else is trying to figure...

    Alright, in case anyone else is trying to figure this out I think I got it. You need to work with money in cents. So $35.96 is 3596 in pennies, you need to store that number in an int. If you are...
  11. Replies
    18
    Views
    3,265

    Working with money?

    I know you don't want to use floating point numbers when working with money because of the rounding errors, but instead use integers. I read somewhere that you should "multiply by 100, add 0.5,...
  12. Replies
    4
    Views
    757

    *Smacks forehead* Thank you both, good...

    *Smacks forehead*

    Thank you both, good suggestion ooga!
  13. Replies
    4
    Views
    757

    Card game, having a problem with strings.

    In the shuffleDeck function, I'm printing out "cards" in the while loop and I'm getting junk after some of the strings along with a segfault at the bottom of the list. I tried using realloc, in order...
  14. That code I posted was just a quick example, in...

    That code I posted was just a quick example, in my actual program I checked for a NULL file and used free() for the dynamic memory alloc. But I wasn't aware casting malloc was bad practice, thanks.
  15. Nevermind, I just figured it out! I wasn't...

    Nevermind, I just figured it out! I wasn't terminating the strings in the array itself.


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>


    int main(int argc, char *argv[]){
  16. Reading from file into array, some strings aren't terminated?

    I'm making a Jeopardy game and when I read text from a file into arrays to set the categories, questions and answers a couple of the strings are not terminating and they are printing that junk box...
  17. Replies
    2
    Views
    2,465

    Reading from file, segmentation fault

    I'm reading text from a file into an array of strings, when I run the program like this everything works fine, but if I comment out the lines "char letter = 'A'" and the printf two lines below it,...
  18. Replies
    2
    Views
    863

    Reading a file into an array of pointers

    Does anyone know why when I print out "array[2]" nothing prints? It just prints blank space. My file definitely has text in it, but when I try to assign "text" into the array of pointers it won't...
  19. Thread: Using Loops

    by atac
    Replies
    7
    Views
    1,195

    Hmm, the problem with that ^^^ is that it excepts...

    Hmm, the problem with that ^^^ is that it excepts 0 as a valid answer. I would do:



    while(number < 1 || number > 10){
    puts("Incorrect Input");
    scanf("%d", &number); ...
  20. Replies
    3
    Views
    719

    Need help with a calculator

    I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter....
  21. Replies
    1
    Views
    1,970

    Printing a random question from a file

    I'm writing a program that outputs a random question from a file. In the file, I have each question numbered like this 1-5:

    1 Question
    multiple choices...

    2 Question
    multiple choices...
    ...
  22. I never got those warnings. Everything complied...

    I never got those warnings. Everything complied fine for me, but I made those changes you mentioned anyway.
  23. Binary to decimal converter: Bug on greater than 10 digits

    Everything works fine until I enter a binary number that has more than 10 digits. In that case, if I enter eleven '1's, sum will equal 1024 (which is the 10th power of 2) and its not adding the rest....
  24. This was my systematic method of checking if the...

    This was my systematic method of checking if the first string contains the second:
    "aaabababaaasdfg" - (first) string
    "absd" - (second) string

    a (second) = a (first), so
    move to next...
  25. Algorithm help: Find a string in another string?

    My friend gave me this question that he got on a job interview. You're trying to see if its possible for firstString to equal secondString by simply deleting characters in the firstString. You're not...
Results 1 to 25 of 33
Page 1 of 2 1 2