Search:

Type: Posts; User: fazio93

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    6
    Views
    1,452

    yup, that was it. thanks :)

    yup, that was it. thanks :)
  2. Replies
    6
    Views
    1,452

    Alright, so neither feof nor ferror are being...

    Alright, so neither feof nor ferror are being triggered (which they shouldn't because it never gets to then end of the file and an error never occurs because n=1 is a valid call of fgets. i tested it...
  3. Replies
    6
    Views
    1,452

    conceptual question about fgets

    i understand fgets for the most part, but have a (kind of silly) conceptual question about its behavior when allocating 1 as its buffer length, like in the code below. how come when running the...
  4. Replies
    17
    Views
    2,446

    alright, exactly what i was thinking. i just...

    alright, exactly what i was thinking. i just wanted to make sure that wasn't another way of doing it since it didn't make much sense.

    thank you MutantJohn and rcgldr.
  5. Replies
    17
    Views
    2,446

    oops, i wrote it wrong -_-. i meant int* as in...

    oops, i wrote it wrong -_-. i meant int* as in int pointer, my apologies for the confusion. what i meant to say is i can change between (int*) and (int) for the first call of malloc and the program...
  6. Replies
    17
    Views
    2,446

    alright, i guess what's real confusing me then is...

    alright, i guess what's real confusing me then is how the following program can run successfully. i can change the first call of malloc to (row*sizeof(int)) or (row*sizeof(*int)). with the former, if...
  7. Replies
    17
    Views
    2,446

    yes, after writing it out on paper, i see how...

    yes, after writing it out on paper, i see how your method works.

    pertaining to the second question about the int array, i see how the second method would just create one large 1d int array, so...
  8. Replies
    17
    Views
    2,446

    alright, thanks. i have one other (somewhat...

    alright, thanks.
    i have one other (somewhat unrelated) question on using malloc to create 2d arrays

    to create a 2d char array (each row is a string), i would need to create an array of char...
  9. Replies
    17
    Views
    2,446

    alright, i understand now. so in other words,...

    alright, i understand now. so in other words, assignment and arrays should never be mixed at all. the correct way would be:


    int main()
    {

    char *array = malloc(8);
    strcpy(array,"hello");...
  10. Replies
    17
    Views
    2,446

    what exactly is happening? isn't "array" pointing...

    what exactly is happening? isn't "array" pointing to the address of the first byte of that 8 byte memory chunk? what does the compiler assume it is doing?

    thanks
  11. Replies
    17
    Views
    2,446

    dynamic array and assignment operator

    how come when declaring an array dynamically with malloc, you can use the assignment operator and string literals, but with static arrays you must use something like strcpy? does it have to do with...
  12. Replies
    11
    Views
    1,097

    Oh, alright. Because pnum < num+4 isn't...

    Oh, alright. Because pnum < num+4 isn't attempting to reassign num. i understand.

    Thank you all for clearing everything up. Much appreciated.
  13. Replies
    11
    Views
    1,097

    how does the compiler know num+4 isnt an attempt...

    how does the compiler know num+4 isnt an attempt to change the array as num++ would, if num++ == num+1, or is it not the same? Or does the compiler always recognize the "a+N" format as &a[N]
  14. Replies
    11
    Views
    1,097

    wow, i feel stupid. that would be like doing ";i

    wow, i feel stupid. that would be like doing ";i< i+5;i++". i was so focused on the addresses i didn't realize if was affecting both sides.
    this leads me to another question though. how come "num+4"...
  15. Replies
    11
    Views
    1,097

    well, i guess that is my question. why is pnum+4...

    well, i guess that is my question. why is pnum+4 != num+4 if both are the same starting address? what does pnum+4 actually point to, if it is not pointing to the 5th element in num?

    thanks
  16. Replies
    11
    Views
    1,097

    question about incrmenting pointer vs array?

    why does this print "12345"


    #include<stdio.h>

    int main()
    {

    int num[] = {1,2,3,4,5};
    int *pnum = num;
  17. Replies
    4
    Views
    1,118

    never mind. the main.c file was given by my...

    never mind.

    the main.c file was given by my professor for testing purposes, but i was using an older version. he had revised it using gets() instead of scanf, for this very reason.

    thanks...
  18. Replies
    4
    Views
    1,118

    problem with strcpy and ' ' character

    i have a program using an array of structures, with one of the structure's members another structure itself.

    to shorten it, i removed the functions not involved with the issue, but i can post the...
  19. Replies
    11
    Views
    5,093

    thank you, once again :) the 'i' was the...

    thank you, once again :)
    the 'i' was the problem.

    as for the %s warning, i had tried that but didn't think anything of it when i saw i was still getting segfault.
    i've read the that this is more...
  20. Replies
    11
    Views
    5,093

    well, i'm getting segfault again and i believe...

    well, i'm getting segfault again and i believe it's the same reason as before (the loop was never the problem).

    even though i have -Wall in my makefle i only sometimes get a warning from the...
  21. Replies
    11
    Views
    5,093

    yep, i forgot the second part would not even be...

    yep, i forgot the second part would not even be evaulated when it is an OR statement, hence the infinte loop. seems to be working now.
    thanks :)
  22. Replies
    11
    Views
    5,093

    Thing is, we were given the main file as well...

    Thing is, we were given the main file as well just for testing purposes. We actually didnt even cover strings yet as thats a later chapter (which is probably why were given certain parts).



    ...
  23. Replies
    11
    Views
    5,093

    char array segmentation fault

    i want to enter a URL in as a string, and extract just the URL part.

    eg:


    input:
    http://example.com/shop/index.php?product_id=&highlight=blue+shoes&cat_id=&sessionid=123&affid=543

    output:...
  24. Replies
    14
    Views
    6,309

    ok, i understand now. thank you everyone that...

    ok, i understand now. thank you everyone that helped.

    :)
  25. Replies
    14
    Views
    6,309

    thanks, i understand it a bit better now. i guess...

    thanks, i understand it a bit better now. i guess my question is how exactly the added "if" statement fixes the program. if the while statement was by itself (like it was) wouldn't the whole while...
Results 1 to 25 of 29
Page 1 of 2 1 2