Search:

Type: Posts; User: Pole

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Thank you for your advice concerning array of...

    Thank you for your advice concerning array of structures.
    However, I would like to ask if it is possible to keep the initialization the way I have shown, one line per node. It was not shown in my...
  2. Incorrect initializing of a structure instance with data from const char *[][]

    As the topic title says - I have a problem with


    The code:

    #define LANG_EN 0
    #define LANG_PL 1
    #define LANGUAGES 2
    const char *const message[][LANGUAGES] = {
  3. Thank you for the suggestion. However, it does...

    Thank you for the suggestion. However, it does not seem to work on my PC.
    My code:


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


    int main()
    {
  4. Thank you for your help, but it is not applicable...

    Thank you for your help, but it is not applicable for my idea. I am running the app on a microcontroller.

    ------
    I have an idea - is array of string arrays applicable and would solve the problem?
  5. Data structure for storing multiple language versions of my software

    Hello, I have created a simple program for a microcontroller. I have created a menu displayed on an LCD.
    Now I want to add the possibility of choosing a language version, so that a group of strings...
  6. Can't add action to buttons in Visual Studio C++ using Windows Forms

    Hello Dear Community of cprogramming.com!
    I have a following problem - I wrote a simple add_record function using structures (here is my main file):


    // Exercise1.cpp : main project file.
    ...
  7. I did calloc (with a random value - I've chosen...

    I did calloc (with a random value - I've chosen 100) so that I can initialize data->word = ""; data->occ = 0; . This was suggested to avoid SIGSEGV caused by strcmp in search function with a...
  8. EDIT: I can't edit my post so I present new...

    EDIT: I can't edit my post so I present new approach to my code. In gdb I can see that the problem is with iterating my ptr pointer. The program finds words properly, but ptr doesn't change to that...
  9. I don't know how to represent the end of...

    I don't know how to represent the end of constantly updated array of structures.

    My search function must have prototype struct abc *find(char *word)
    so I can't pass that parameter.
  10. OK. So following Your advice I've made: words...

    OK. So following Your advice I've made:

    words *findword(char *word)
    {
    words *ptr = data;

    for (ptr; /*what to put as stop cond. */; ptr++) {
    if ((strcmp(word, ptr->word))...
  11. strdup is from I've only shown parts...

    strdup is from <string.h>
    I've only shown parts relevant to the problem. getword works fine, no need to make a mess in the post and extend it to hundreds of lines of code.
    getword returns char *
  12. word occurence counter 'forgetting' about already saved word

    The snippets below are from my program that gets words, then prints them with the number of occurences.
    It works almost fine - it "forgots" that that entry has been saved before and does NOT...
  13. After doing what You advised - I get a segfault...

    After doing what You advised - I get a segfault
    Here is the change (rest the same as on the previous page), only changed second while loop in main.

    while (((number_next = getnum(infile, base)) !=...
  14. So I guess I should add ((feof(infile) ==...

    So I guess I should add


    ((feof(infile) == 0) || (number1 = getnum(infile, base) != NULL )) number1 instead of number 2, as @oogabooga said.
  15. valgrind -v gives me no errors, so I guess no...

    valgrind -v gives me no errors, so I guess no memory leak there.

    Fixed, thank You.
    But, condition
    (feof(infile) == 0) is not always true. What if a file would be empty?

    Yeah, I got it...
  16. @Matticus - I got it working, thank You! ...

    @Matticus - I got it working, thank You!


    @oogabooga I quoted your post, why did you suggest that change in while condition? Is the one presented in the code in the first post prone to some...
  17. I did as You advised. However, now program hangs...

    I did as You advised. However, now program hangs after invoking, and I have to press Ctrl+C to stop it.
    I only changed main(), posting it below:

    int main(int argc, char **argv)
    {
    FILE...
  18. If I decide to store it in an array that would be...

    If I decide to store it in an array that would be a two-dimensional array. Then how to pass those strings, two at a time, and keep the result of the previous operation as one of the parameters passed...
  19. Thanks for reply. I have another question though....

    Thanks for reply. I have another question though. How to implement contnuous search and assignment for new numbers read from file. I mean, firstly assign
    number = getnum(infile, base) and then how...
  20. OMG oogabooga You helped me a lot! I'd never get...

    OMG oogabooga You helped me a lot!
    I'd never get to that, I was expecting memory management is incorrect, and I was looking into it mainly.
    The program is supposed to run as
    ./name input.txt...
  21. program adding numbers using desired base doesn't show any output

    Hello, I have a problem with an "add calculator".
    Valgrind reports no memory errors, no errors from compiler but the program doesn't show any output despite the printf - "Result is zero".

    All...
  22. Replies
    15
    Views
    3,711

    Yeah, but which line assigns '5' to s[0] ?

    Yeah, but which line assigns '5' to s[0] ?
  23. I appreciate Your help very much, however again...

    I appreciate Your help very much, however again it doesn't work properly. At least now, there's no segmentation fault ;)

    isdigit seems to be not detecting numbers, and even though I clear the...
  24. Replies
    15
    Views
    3,711

    So apparently it is the other way round (than I...

    So apparently it is the other way round (than I thought), 6 overwrites \0 which was previously there at s[1] created by line 84?
  25. Replies
    15
    Views
    3,711

    Big thanks, now I understand every thing You had...

    Big thanks, now I understand every thing You had written about.
    However I still wonder about that - "What if 567 is entered ? 5 would be array[0], 6 in array[1], 7 in array[2] and 6 from array[1]...
Results 1 to 25 of 44
Page 1 of 2 1 2