Search:

Type: Posts; User: Mentallic

Page 1 of 8 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    645

    Ahh nice, an easy solution. Thanks guys!

    Ahh nice, an easy solution. Thanks guys!
  2. Replies
    3
    Views
    645

    Variable strings

    I have an array of strings char string[n][MAX_FILE_NAME] and in each string I want to initialize it with the name of a bunch of files I have. string[0] should be "txt_0", string[1] = "txt_1" etc.
    ...
  3. Replies
    2
    Views
    639

    I tried that at first and it didn't seem like it...

    I tried that at first and it didn't seem like it worked, but it was actually a problem I had elsewhere that made me think it failed. Thanks for helping me notice it.
  4. Replies
    2
    Views
    639

    Change struct pointers

    I have a linked list where each node contains a pointer to a string, I'm treating the linked list as a text file and each node/string contains each line in the text file.

    I have all of that...
  5. Replies
    5
    Views
    877

    Oh I see. The new line isn't a big deal for me in...

    Oh I see. The new line isn't a big deal for me in this case, I was just worried that I was doing something wrong.



    Right, thanks. I'll go ahead and add


    text[0] = '\0'

    after I malloc.
  6. Replies
    5
    Views
    877

    fgets new line at end

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

    #define MAX_COL 70
    #define MAX_ROW 20


    int main(void) {
    FILE *fp;
  7. Replies
    2
    Views
    717

    The missing line that you pointed out was the...

    The missing line that you pointed out was the problem... That's pretty embarrassing haha :redface:

    That diff tool is a good idea. Thanks!
  8. Replies
    2
    Views
    717

    Two "equivalent" functions

    I made an attempt to shorten my code in a particular function because it had lines that repeated themselves.

    The function that has duplicate lines but works


    static Line newLines (char text[])...
  9. Replies
    8
    Views
    1,112

    Derp... I've made that mistake in the past as...

    Derp... I've made that mistake in the past as well. It's just hard to override some common sense sometimes. The fact that I let list = NULL and then curr = list, and while I gave room to list on the...
  10. Replies
    8
    Views
    1,112

    Well spotted. In the function that's causing...

    Well spotted.


    In the function that's causing the seg fault


    static Line newLines (char text[]) {
    Line list = NULL, curr = list;
    int lineCount = 1;
    int length = strlen(text);
  11. Replies
    8
    Views
    1,112

    Due to popular criticism, I removed the asserts...

    Due to popular criticism, I removed the asserts :biggrin:

    I'm having a seg fault that I just don't understand...


    //Compile: gcc -Wall -Werror -O -o text textbuffer.c tests.c

    #include...
  12. Replies
    8
    Views
    1,112

    Oh right, I totally forgot about the ampersand. ...

    Oh right, I totally forgot about the ampersand.



    I'm all for learning better coding practises, unless it deviates from my professor's style. I appreciate your tips but changing it would just...
  13. Thread: Can't free

    by Mentallic
    Replies
    4
    Views
    1,201

    Ok cheers for that :)

    Ok cheers for that :)
  14. Replies
    8
    Views
    1,112

    Make a string out of part of a string

    I have a string that contains a various number of lines which are each separated by \n and so what I want to do is to put each line into a node in a linked list.

    The relevant sections in my code...
  15. Thread: Can't free

    by Mentallic
    Replies
    4
    Views
    1,201

    That makes perfect sense! Thank you tabstop. ...

    That makes perfect sense! Thank you tabstop.

    edit: Just one more thing. If I set the pointer to the struct to NULL, then I've basically lost the position of the struct in memory, hence I've also...
  16. Thread: Can't free

    by Mentallic
    Replies
    4
    Views
    1,201

    Can't free

    I'm working on an assignment that handles text and operations on the text. What I have so far is


    //tests.c
    //Compile: gcc -Wall -Werror -O -o text textbuffer.c tests.c

    #include <stdio.h>...
  17. Replies
    9
    Views
    1,272

    I think I see what it's doing. It's going to be...

    I think I see what it's doing. It's going to be consuming each character in the input buffer including the new line character, but breaks from the while loop when that happens so it stops waiting for...
  18. Replies
    9
    Views
    1,272

    I see. Sadly, I don't know how to do that. ...

    I see. Sadly, I don't know how to do that.



    Thanks, I noticed it too, and I would've spotted it even earlier if I used the -Wall flag :)
  19. Replies
    9
    Views
    1,272

    Can't stop while loop

    I'm trying to create a connect four game, but I've ran into a problem while trying to read valid user input.


    // 4 in a row game

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

    #define NUM_ROWS 6...
  20. Replies
    9
    Views
    821

    Thanks Hodor, that makes a lot of sense now. ...

    Thanks Hodor, that makes a lot of sense now.



    If I use

    enum BOOL {FALSE, TRUE}
    then I'm guessing FALSE is replaced with 0 and TRUE with 1, right? But do I also need to add this enum line...
  21. Replies
    9
    Views
    821

    That won't do because I'm going to be using the...

    That won't do because I'm going to be using the numbers I scanned in not only in the function, but later on outside of the function too.


    Yes, thanks for spotting that.


    I'll be using it a...
  22. Replies
    9
    Views
    821

    Passing pointers into function

    I want to scan numbers in from within a function, but have access to them in main, so I tried using pointers to do so:



    // Path Of Exile socket colours simulation

    #include <stdio.h>...
  23. Replies
    16
    Views
    2,688

    But I don't know how many strings I'll need to...

    But I don't know how many strings I'll need to put into messages. If I make it messages[n] then I'm set on having only up to n strings, but may need more.




    But my assignment has a .h file...
  24. Replies
    16
    Views
    2,688

    Does the array have room? The messages[] that...

    Does the array have room? The messages[] that doesn't actually have a size associated with it at compile time is confusing me. How much room is there? Can I put as many strings in as I want?


    ...
  25. Replies
    16
    Views
    2,688

    I'm unsure to be honest. I'm working on the...

    I'm unsure to be honest. I'm working on the terminal that comes with ubuntu and I'm using gcc with no flags to compile the file.



    My current code isn't the issue (at least it shouldn't be). I'm...
Results 1 to 25 of 176
Page 1 of 8 1 2 3 4