Search:

Type: Posts; User: ZuK

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    1
    Views
    523

    printf("Your Total Price is :%d", TotalPrice); ...

    printf("Your Total Price is :%d", TotalPrice);
    You're using the wrong fotmat to print a float %d is for integers
    And then you should calculate TotalPrice before printing it's value.
    Kurt
  2. Replies
    7
    Views
    619

    I'd put include guards around the code in...

    I'd put include guards around the code in Array2d.h.
    Guess that #pragma once thingy does the same thing
    Kurt
  3. Assign the values of a and b to num after reading...

    Assign the values of a and b to num after reading a and b from the stream
    Kurt
  4. Replies
    8
    Views
    647

    Replacing a single character with 2 or even 3...

    Replacing a single character with 2 or even 3 characters will invalidate the iterator.
    Try string::find in a loop.
    Also the allocated buffer has no space for a terminating 0 that you fail to...
  5. 1; remove that line char *moo = str; moo is...

    1; remove that line

    char *moo = str;
    moo is never used

    2: NULL is defined as a pointer type. You want to compare to the 0 character -> use '\0'
    Kurt
  6. Replies
    3
    Views
    611

    for(int i =0; i

    for(int i =0; i<10; i++)
    {
    cout <<a<<"\n";
    *b++; //shouldn't this assigned a new value to a??
    }

    the post increment operater will be executed first -> first the pointer...
  7. Thread: counting strings

    by ZuK
    Replies
    21
    Views
    1,022

    as I said before try while ( getline(infile,...

    as I said before try

    while ( getline(infile, s) ) {
    ... // your for loop
    }

    And you are still accessing the string out of bounds

    Kurt
  8. Thread: counting strings

    by ZuK
    Replies
    21
    Views
    1,022

    Yes, you could put the getline call as the...

    Yes, you could put the getline call as the condition for a while loop.
    The other mistake is that sizeof() wont return the length of the string
    Kurt
  9. Thread: counting strings

    by ZuK
    Replies
    21
    Views
    1,022

    if(s[i]=='a'&&'n'&&'d') that won't do what you...

    if(s[i]=='a'&&'n'&&'d')

    that won't do what you want, it will be true for each 'a'
    try

    if(s[i]=='a' && s[i+1]='n' && s[i+2]=='d')

    Beware of out of bounds accesss

    Kurt
  10. Thread: Undefined behavior

    by ZuK
    Replies
    14
    Views
    959

    You didn't modify the data the const char *...

    You didn't modify the data the const char * points to. Just reassigned it. That's allowed

    Kurt
  11. Thread: why stop working?

    by ZuK
    Replies
    5
    Views
    548

    The variable countz on line 9 is not declared....

    The variable countz on line 9 is not declared. Your program shouldn't compile.
    If you change the variable to count then the reason for the crash is the format of your printf call. "%s" is used for...
  12. Thread: Divide fail

    by ZuK
    Replies
    10
    Views
    736

    num1 and num2 are both integers so the result of...

    num1 and num2 are both integers so the result of the division is an int too. "%f" expects a float
    Kurt
  13. Thread: Vectors:

    by ZuK
    Replies
    12
    Views
    1,157

    averageGrades(grades[i],numGrades);...

    averageGrades(grades[i],numGrades);
    averageGrades() expects a pointer to int, you're passing an int

    Better would be to pass a const reference to vector<int> to averageGrades(). This way you...
  14. Replies
    13
    Views
    18,655

    You cannot find the ascii value of a complete...

    You cannot find the ascii value of a complete string
    to get the ascii value of a single character you could just cast it to an int



    char * str = "HELLO";
    int i, cnt = strlen(str);
    for ( i =...
  15. void number_generator(numbers[6]) //warning...

    void number_generator(numbers[6]) //warning specifier missing, defaults to 'int'
    as the error says there is no type specifier
    try

    void number_generator(int numbers[6])
    ...
  16. Replies
    20
    Views
    1,848

    You use assignment when you want to compare for...

    You use assignment when you want to compare for equality all over.
    Kurt
  17. Thread: while(!feof(f))...

    by ZuK
    Replies
    5
    Views
    1,748

    Generally there is nothing wrong to use feof()....

    Generally there is nothing wrong to use feof(). You just have to know that EOF is set after scanning has failed, that means that you still have to check the return value of your fscanf() calls. If...
  18. Thread: while(!feof(f))...

    by ZuK
    Replies
    5
    Views
    1,748

    fscanf(f,"%c",fitxer[i].cTipus); ...

    fscanf(f,"%c",fitxer[i].cTipus);
    fscanf(f,"%d", fitxer[i].nCasella);
    fscanf expects the address of the varibles to read.
    Kurt
  19. Replies
    27
    Views
    1,381

    true, Vectors ar copyable this ...

    true, Vectors ar copyable

    this


    vector<int>message1(n);


    for(int i=0;i<message.size();i++)
    {
  20. Replies
    4
    Views
    841

    I understand but the num in passengersR () is a...

    I understand but the num in passengersR () is a different num from the one in main.
    Guess you have to pass it as a parameter to the function
    e.g.

    double passengersR ( int num ) {
    double...
  21. Replies
    4
    Views
    841

    double passengersR (); // this is a declaration...

    double passengersR (); // this is a declaration of the function passengersR
    double m; // Here a variable m is declared, its value is undefined
    guess that is not what you want


    double m...
  22. Thread: Characters again

    by ZuK
    Replies
    12
    Views
    909

    casella[96].nX1 = 240; casella[96].nX2 =...

    casella[96].nX1 = 240;
    casella[96].nX2 = 0;
    casella[96].nY1 = 0;
    casella[96].nY2 = 60;
    casella[96].nTextx = 4;
    casella[96].nTexty = 4;
    casella[96].nColor =...
  23. Replies
    17
    Views
    1,048

    some commas are missing kurt

    some commas are missing
    kurt
  24. Don't return from inside the loop. If you'd...

    Don't return from inside the loop.
    If you'd indent the code better the mistake would be obvious.
    Kurt
  25. The second time there will be a \n in the input...

    The second time there will be a \n in the input buffer and the scanf("%c", &op ) will read that as op.
    simple fix: put getchar(); after scanf("%d%d", &num1, &num2);

    Kurt
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4