Search:

Type: Posts; User: [Ren]

Search: Search took 0.01 seconds.

  1. Thread: Is this correct?

    by [Ren]
    Replies
    14
    Views
    1,372

    The code is right. The description is not. argv...

    The code is right. The description is not. argv is an array of pointer to char.
  2. Thread: read line

    by [Ren]
    Replies
    12
    Views
    1,696

    You are trying to use a function declaration...

    You are trying to use a function declaration where a function call is expected. Also, functions can not be defined inside of other functions.
  3. Replies
    16
    Views
    4,695

    You wrote this and expect so many errors? Or is...

    You wrote this and expect so many errors? Or is this an assignment that you have to do?
  4. Thread: Searching

    by [Ren]
    Replies
    23
    Views
    2,800

    Just for fun. char *str_isearch(const char...

    Just for fun.


    char *str_isearch(const char *s, const char *match)
    {
    do {
    const char *r = s, *p = match;
    while (*p != '\0'&& *s != '\0' && *s == *p)
    ++p, ++s;...
  5. Thread: Q's

    by [Ren]
    Replies
    15
    Views
    2,748

    // Static array float a[10]; // Dynamic array...

    // Static array
    float a[10];
    // Dynamic array
    float *b = new float[10];

    // Get size for static array
    int size1 = sizeof a / sizeof a[0];
    // Get size for dynamic array
    int size2 = 10;
  6. Replies
    2
    Views
    4,009

    In insert, if the node is found, increment...

    In insert, if the node is found, increment counter. If the node is not found, set counter to 1. Now, to print each letter with the number of occurances, you just need to traverse the tree.

    ...
  7. Thread: Q's

    by [Ren]
    Replies
    15
    Views
    2,748

    in is not a C++ keyword. What IDE are you using?...

    in is not a C++ keyword. What IDE are you using?

    Use std::vector in the <vector> header. It is much easier than dynamic arrays.

    Yes, you can. Just call the method without a qualifier.
  8. Thread: Searching

    by [Ren]
    Replies
    23
    Views
    2,800

    Not more efficient than what? Calling malloc...

    Not more efficient than what? Calling malloc twice to make copies? Or modifying the original string to be upper or lower case?

    Performance is at most 2N * M times where M is the number of...
  9. Thread: Searching

    by [Ren]
    Replies
    23
    Views
    2,800

    char *caseInSensitive(char *string, char *match)...

    char *caseInSensitive(char *string, char *match)
    {

    char *pos, *string2, *match2;
    int i;

    for (i=0;i<strlen(string);i++)
    (string2)[i]=tolower((string)[i]);

    for...
  10. Thread: Searching

    by [Ren]
    Replies
    23
    Views
    2,800

    for (i=0;i

    for (i=0;i<strlen(string);i++)
    (string)[i]=tolower((string)[i]);

    for (i=0;i<strlen(match);i++)
    (match)[i]=tolower((match)[i]);

    What if either string or match is a string literal? C does...
  11. Replies
    2
    Views
    1,000

    It is only 3 characters... Menu_Opt[0] =...

    It is only 3 characters...


    Menu_Opt[0] = toupper(Menu_Opt[0]);
    // Within [10..60)
    int value = atoi(Menu_Opt + 1);
    if (value < 10 || value > 59)
    error();

    You can put the validation in a...
  12. Replies
    2
    Views
    3,109

    It does not matter. Iterators will be copied...

    It does not matter. Iterators will be copied correctly regardless of the internal implementation. The iterator will be copied and your only problem is if the container is a local object.

    A pointer...
  13. Because you using ASCII, just add 1 to each...

    Because you using ASCII, just add 1 to each string character.


    #include <iostream>
    #include <string>

    using namespace std;

    int main()
    {
  14. Replies
    6
    Views
    4,685

    char* sub_string = malloc(50 * sizeof...

    char* sub_string = malloc(50 * sizeof *sub_string);
    char* rest_string;

    if (sub_string == NULL)
    return NULL;

    /* Rest of code */
  15. Replies
    35
    Views
    6,300

    goto is fine if used carefully. A good time for...

    goto is fine if used carefully. A good time for goto is common error handling code or leaving a deeply nested loop. Programs with need for performance can use goto too. While goto can be replaced...
  16. Replies
    16
    Views
    4,200

    Simple encryption in C++ is easy. #include...

    Simple encryption in C++ is easy.


    #include <iostream>
    #include <string>

    using namespace std;

    namespace {
    string keys = "~!@#$%^&*()_+|}{\":?><,./;\'][=-`";
  17. Replies
    24
    Views
    3,221

    a, so. When using sizeof, is it not better to...

    a, so. When using sizeof, is it not better to avoid using the type directly?


    char *p = malloc(10 * sizeof *p);
  18. Replies
    24
    Views
    3,221

    sizeof(char) is always 1. Code is simpler by...

    sizeof(char) is always 1. Code is simpler by removing the multiplication.


    char *p = malloc(10);
    if (p == NULL) {
    perror("malloc");
    return 1;
    }
  19. Replies
    11
    Views
    16,443

    New nodes need malloc to be called each time. You...

    New nodes need malloc to be called each time. You were using the same node for all inserts.


    int main(void)
    {
    node *curr=NULL, *root= NULL;

    do
    {
    curr = (node...
  20. Replies
    2
    Views
    1,213

    My guess is Terms does not copy right. May I see...

    My guess is Terms does not copy right. May I see code for Terms?
Results 1 to 20 of 21