Search:

Type: Posts; User: heinz55

Search: Search took 0.00 seconds.

  1. Replies
    8
    Views
    823

    #include int main() { int a;...

    #include <stdio.h>

    int main()
    {
    int a;
    int b;
    int c;

    printf("Welcome to addition!\n");
    printf("First Number: ");
  2. Replies
    9
    Views
    1,358

    I may have had a moment of weakness when I wrote...

    I may have had a moment of weakness when I wrote the first post. And hopefully my "way too modest math abilities" will not jeopardize my coding career.

    But the fact is that back in the school I...
  3. Replies
    9
    Views
    1,358

    Coder with weak math skills

    Hello.

    I have this question: if I must describe myself as "not actually a math guy", do I ever have a chance to become a great coder?

    My strong side have always been arts and literature. And...
  4. Thread: Reading files

    by heinz55
    Replies
    2
    Views
    832

    Thank you for explaining. I had no idea fseek()...

    Thank you for explaining. I had no idea fseek() behaves that way.
  5. Thread: Reading files

    by heinz55
    Replies
    2
    Views
    832

    Reading files

    Hello,

    I have a question related to this code:




    #include <stdio.h>
    #include <stdlib.h>
  6. Actually your code is pure C not C++. Anyway,...

    Actually your code is pure C not C++.

    Anyway, this particular code should not give us any output. So it's quite a mystery how did you get this "0 1 2 0".
    What compiler are you using?
  7. Thread: Vector

    by heinz55
    Replies
    2
    Views
    667

    Imagine something like this: int...

    Imagine something like this:



    int num_list[5] = {1, 5, 77, 3, 35}; // has only 5 elements

    cout << num_list[6] << endl; // but 6-th element is also accessible
    cout << num_list[-7] << endl;...
  8. Replies
    9
    Views
    933

    For loops and system memory

    Hello,

    I have a question about those code snippets below.

    Sample A:


    for(int i=0; i<getSomeLenght(); i++) {
    // Some code here
    }
  9. Thread: simple

    by heinz55
    Replies
    2
    Views
    636

    Since char takes only one byte, a[30] reserves...

    Since char takes only one byte, a[30] reserves exactly 30 bytes.
  10. Replies
    17
    Views
    2,627

    Try exit(0); not just exit();

    Try exit(0); not just exit();
  11. Replies
    17
    Views
    2,627

    Sorry I must've misunderstood you. Do you mean...

    Sorry I must've misunderstood you. Do you mean exit the entire program? Or just exit the function?
  12. Replies
    17
    Views
    2,627

    In void function just write 'return' void...

    In void function just write 'return'



    void someFunction(void)
    {
    /* some code here */

    return;
    }
  13. Replies
    8
    Views
    3,126

    void hello(const char *message, const char...

    void hello(const char *message, const char *testMsg="Testing...\n")

    Aren't default parameters illegal in 'C'? However, in 'C++' they are perfectly acceptable.
  14. Replies
    21
    Views
    3,519

    Indentation style and personality

    Hello,

    I was wondering if there is any connection between programmer's personality type and his/her favourite brace style?

    As I have noticed, large amount of coders seem to prefer either K&R or...
  15. Replies
    3
    Views
    1,419

    Weird behaviour of "inline if"

    Hello,

    Can someone explain why "inline if" does not work in this particular example:



    #include <iostream>
    using namespace std;

    string replaceStr(string source, char a, string b)
  16. Replies
    7
    Views
    2,930

    Using free() function

    Could someone explain what is the most correct usage of free() function in this paricular case:



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


    void reverseStr(const char...
  17. Replies
    11
    Views
    1,624

    I'm just trying to write C code that can be...

    I'm just trying to write C code that can be compiled with C++ compilers as well. Simple as that.
    But if I write C++ then I try to keep it pure C++.
  18. Replies
    11
    Views
    1,624

    You are correct, but traditional C does not...

    You are correct, but traditional C does not support the "new" keyword.
  19. Replies
    11
    Views
    1,624

    Thanks for the advices given so far. I'll try to...

    Thanks for the advices given so far. I'll try to follow at least most of them.

    Just a brief note considering this line:


    PERSON *p = (PERSON *)malloc(sizeof(PERSON));

    Since I try to make my...
  20. Replies
    11
    Views
    1,624

    Problems with recursive structure

    Hello,

    I'm trying to understand the logic of recursive structures (or is "linked list" much proper term?) and I have a problem with following code:


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

    ...
  21. Replies
    11
    Views
    6,940

    Too long string causes segmentation fault

    Hello.

    This simple code was nicely working:


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

    int main(void)
    {
  22. Replies
    5
    Views
    7,506

    Yes it really works! All the other tricks I tried...

    Yes it really works! All the other tricks I tried caused whether errors or segmentation faults.
    Thank you so much.
  23. Replies
    5
    Views
    7,506

    Changing string value via function

    Here is my simple working program:


    #include <stdio.h>

    #define CHANGE_STR(old_str, new_str) (old_str = new_str)

    int main(void)
    {
    char *msg = "This is old message.";
Results 1 to 23 of 23