Narue 5,707 Bad Cop Team Colleague

scanf() can be used in this case, but it's a lot more work, because of the '.' and filename extension after it.

Eh? I see no reason why scanf() would be harder for those reasons. The %s specifier uses whitespace as a delimiter:

char filename[50];

if (scanf("%49s", filename) == 1) {
    /* Yay! */
}
else {
    /* Boo! */
}

However, modern operating systems allow embedded whitespace, and that's a good reason to avoid the %s specifier. Though you could use a scanset to read the full line:

char filename[50];

if (scanf("%49[^\n]", filename) == 1) {
    /* Yay! */
}
else {
    /* Boo! */
}

That said, I'd still recommend fgets(). ;)

Narue 5,707 Bad Cop Team Colleague

i know one method is thru va_arg related macros...is there any other method....wot wud u do...if the code skeleton looks something like this...

int sum_fun(int num_arg,...)
{

....
...
...


}


main()
{

printf("%d",sum_fun(4,4,5,6,7));
printf("%d",sum_fun(8,1,2,3,4,5,6,9,10));
...
..
..
}

If you're using the ... notation for variable parameters, the only portable option for processing those parameters is the varargs macros. You could rewrite those macros to do the same thing, but that's silly and strictly tied to the compiler.

Narue 5,707 Bad Cop Team Colleague

Function calls use parentheses, not braces:

System.Console.Writeline("this is my program")
System.Console.ReadLine()
Narue 5,707 Bad Cop Team Colleague

When you're talking about runtime

I'm talking about the conceptual difference, not runtime or compile time. Is that "abstract" enough for you?

The wording of my answer had to do with "abstract representation" in the OP's title.

So calling a blatantly incorrect explanation "abstract" suddenly makes it correct? Who knew? :icon_rolleyes: Maybe you should wait until the OP clarifies the question before trying to answer.

Narue 5,707 Bad Cop Team Colleague

An array is just a pointer.

Wrong. An array name when used in value context is converted to a pointer to the first element. But an array is not a pointer, which is easily proven by switching to an object context:

#include <stdio.h>

int main(void)
{
    int a[] = {1,2,3,4,5};
    int *p = &a[0];

    printf("%zd\n%zd\n", sizeof a, sizeof p);

    return 0;
}

Also, notice how some people use "char* argv[]" and others use "char** argv"? They're both the same thing for that very reason.

It's a shame that this notation was allowed, because it's both the source of and continued cause for confusion about pointers and arrays. Also note that it's only allowed on the first dimension of an array. void foo(int a[][10]) is not equivalent to void foo(int **p) .

Narue 5,707 Bad Cop Team Colleague

Even when I comment out all the libraries

And by "comment out all the libraries" do you mean you're commenting out the headers? Because that's not what I was talking about in the slightest.

Narue 5,707 Bad Cop Team Colleague

I'd be willing to bet that you're not linking with all of the required libraries.

Narue 5,707 Bad Cop Team Colleague

I heard I could do this with multithreading (which apparently is very complicated).

You heard correctly. While threading is conceptually very simple, the subtle and difficult to trace errors of shared data access makes it among the harder things that most programmers have to deal with.

Is there any other way to do this?

Not if your goal is to avoid the complexity of threads. Other methods of achieving concurrency are just as complicated.

If not, where should I start to learn about threads and multithreading (I have never used threads/anything like this before)?

Have you tried Google?

Narue 5,707 Bad Cop Team Colleague

An error like what? Are we to supposed to read your mind to see the error message?

Narue 5,707 Bad Cop Team Colleague

what should I do with the vowels? should I set an array for it?

I've always seen people write a small helper function:

#include <ctype.h>

int is_vowel(int ch)
{
    ch = tolower((unsigned char)ch);

    return ch == 'a' || ch == 'e' || ch == 'i' || 
           ch == 'o' || ch == 'u';
}

Regarding the void main(), our professor once used it so, um, I was just using it.

If your professor requires it, use it. But be aware that void main is wrong, and your professor probably doesn't know C well enough to teach it properly. Be skeptical about whatever he tells you.

Narue 5,707 Bad Cop Team Colleague

Pass an array.

Narue 5,707 Bad Cop Team Colleague

Is that the exact question you have, or are you paraphrasing it into incoherence?

Narue 5,707 Bad Cop Team Colleague

Examples of how do you handle returning references by properties?

Do you just return the reference or return the clone?

There's no cloning going on:

class Car {
    private Engine _engine;
    public Engine Engine {
        get { return _engine; }
        set {
            if (value.HP > 200)
                throw new ArgumentException("Horsepower too high for car model");

            _engine = value;
        }
    }

    public Car() {
        Engine = new Engine(400);
    }
}

If you're worried about aliases then you can clone on the set of your property:

set {
    // ...
    _engine = value.Clone();
}

But I'd ask for a use case that actually fails due to aliasing, otherwise you're making an unnecessary clone.

The horsepower check is a little odd as well. That doesn't seem like the place it should be to me. The restriction for placing an engine in a car really has nothing to do with horsepower. In fact, unless you're supporting some sort of feature for non-stock engine swaps, it would be best to base the engine on the model and not expose a public set at all:

abstract class Car {
    public Engine Engine { get; protected set; }
}

class SomeSpecificModel: Car {
    public SomeSpecificModel() {
        Engine = new Engine(400);
    }
}

Now the horsepower is a non-issue because it's assumed to be stock, and you can use an auto-property.

Narue 5,707 Bad Cop Team Colleague

Can you please give some examples?

Examples of what?

Narue 5,707 Bad Cop Team Colleague

What are the best practices about using properties in C#?

Best practice is really no different from parameters and return values from functions. If you can get away with a reference, do so. It's generally more efficient for both space and execution time. Not to mention that it's easier to reason about a single object's lifetime than multiple copies of the object.

Narue 5,707 Bad Cop Team Colleague

C should be CONCISE, (short, and to the point), not a Rube Goldberg deluxe creation. Simple and clear are secondary goals to accuracy, but important one's nevertheless.

Concise and clear can easily be mutually exclusive. For example:

#include <stdio.h>

#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min3(a,b,c) (min(a, min(b, c)))
#define max3(a,b,c) (max(a, max(b, c)))
#define mid3(a,b,c) \
    ((a) > (b) && (a) > (c) ? \
        max(b, c) : \
        ((a) < (b) && (b) > (c) ? max(a, c) : max(a, b)))

int main(void)
{
    int x, y, z;
    
    printf("Enter three integers: ");
    fflush(stdout);
    
    if (scanf("%d%d%d", &x, &y, &z) == 3) {
        printf("%d %d %d\n", min3(x, y, z), mid3(x, y, z), max3(x, y, z));
        printf("Sum: %d\n", x + y + z);
    }
    
    return 0;
}

This program does the same thing, but that mid3() macro is a bear even with the helper macros. This is a case where concise might be a bad thing because it hurts clarity.

Narue 5,707 Bad Cop Team Colleague

You can do most of the work in scanf(). For example:

fscanf(in, " %*[Zz]%d %[^\n]", &index, buf);
fgetc(in); /* Discard the newline (if present) */

It's not quite as good as a regular expression, but suffices for strict formats. There's also extra work interpreting the values, but all of this is straightforward once you have the index and the string:

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

int main(void)
{
    FILE *in = fopen("test.txt", "r");

    if (in != NULL) {
        char buf[BUFSIZ];
        char (*data)[6];  /* Assuming that data lines are 5 characters exactly */
        int rows = 0;

        /* Count the lines in our file */
        while (fgets(buf, sizeof buf, in) != NULL)
            ++rows;

        clearerr(in); /* Good idea before C99, now required */
        rewind(in);

        data = malloc(rows * sizeof *data);

        if (data != NULL) {
            int index;
            int i;

            /* Hedge against a malformed file */
            for (i = 0; i < rows; i++)
                data[i][0] = '\0';

            /* At last we can parse the file as desired */
            while (fscanf(in, " %*[Zz]%d %[^\n]", &index, buf) == 2) {
                fgetc(in); /* Discard the newline (if present) */

                /* Correct the 1-based indices in our file */
                if (index > 0 && index <= rows)
                    strcpy(data[index - 1], buf);
            }

            /* Print a report of the properly ordered lines */
            for (i = 0; i < rows; i++) {
                printf("%d: '%s'", i + 1, data[i]);
                
                if (data[i][0] != '\0')
                    puts("");
                else
                    puts(" Potentially malformed file detected");
            }

            free(data);
        }
    }

    return …
Narue 5,707 Bad Cop Team Colleague

i just know how to concatenate two strings but when inserting a character in a string im totally lost .

Well, think about it as if the characters were boxes lined up. If you want to put a box somewhere in the middle, you need to make room somehow. Usually the two methods of making room are swapping an existing box with the new box, and shoving boxes out of the way.

Since order matters, shoving boxes works better:

Given a row of boxes
[c][a][f][e]

Find where you want to place new boxes
[c][a]|[f][e]

Shove boxes out of the way to make room
[c][a]      [f][e]

Set the new box(s) down
[c][a][x][z][f][e]

This process is easily translated to an algorithm.

Narue 5,707 Bad Cop Team Colleague

i tried to count '-' signs in the string (see below)

That won't work, for the very reason you stated. You need to be strict in the format of the string, because non-digit characters are allowed, but in very specific locations and circumstances.

I'd recommend ditching what you have and starting over with nothing but a floating-point lexer. Take a string and break it down into the component parts while also validating the format. Once you can do that with 100% accuracy on the grammar you're using, the pieces can be parsed to extract a real value.

Narue 5,707 Bad Cop Team Colleague

what thing makes this program print out a rhyme rather than a compiler error

It's not invalid code[1], just very difficult to read. If you really want to understand it, a good start would be reformatting the code into something more sensible. That alone is a decent exercise, but not one I would recommend for a beginner. As already mentioned, at this point you'll learn more by studying good code than intentionally bad code.

I don't think they are non-portable, I compiled them and found a fair amount of success under Code::Blocks 10.05.

So you tested them on one version of one compiler, had a "fair amount" of success, and have the rocks to say that they're portable? Do you understand what portable means?


[1] Technically it is invalid because it's K&R C rather than standard C (the entry was for the 1988 IOCCC, if I recall correctly). Modern compilers will probably fail to run it even if they don't choke on the pre-standard syntax.

Narue 5,707 Bad Cop Team Colleague

There are multiple ways of doing it, but in my opinion the most instructive is with a level order traversal, since checking for a complete binary tree is a pretty specific operation. By generalizing the problem a bit, you can get more out of the exercise. So here's an updated problem for you:

Q: Given a binary tree of the following definition:

struct node {
    int data;
    struct node *left;
    struct node *right;
};

Write a function that will perform a level order traversal and convert the tree into an array using heap indexing rules. Heap indexing rules state that for each node (numbered 0 to N in level order) the left child is at index 2 * i + 1 and the right child is at 2 * i + 2 .

As an example, given the following degenerate binary tree:

1
        -                      2
   -         -             -        3
 -   -     -   -         -   -    -   4
- - - -   - - - -       - -  - - - - - 5

The array you are to return might look like this:

1-2---3-------4---------------5

Once you have this array, determine if it represents a complete binary tree by testing for null nodes in between non-null nodes. A complete binary tree will have all non-null nodes strictly adjacent to each other. For example, here is a complete binary tree and the array representation:

5
  2         7
1   3     6   -
527136-

Note: The size …

N1GHTS commented: Your effort deserves credit +6
Narue 5,707 Bad Cop Team Colleague

I see no provision for negative numbers (or any sign at all). Usually it follows logic similar to this (greatly simplified):

if (*s == '-' || *s == '+') {
    sign = *s++;
}

/* Convert the number */

if (sign == '-')
    value = -value;
Narue 5,707 Bad Cop Team Colleague

can anyone explain to me how this program works.

Can I? Yes, this program is actually very well known as it was an early winner of the IOCCC. Will I explain it to you? No, IOCCC programs are written by very clever people, and the techniques implemented are virtually useless outside of the contest and often non-portable. As a beginner to C you'd be wise to learn from well written code rather than intentionally bad code.

Narue 5,707 Bad Cop Team Colleague

The error makes sense. How do you find "" to replace? Are you trying to replace nothing? Every character? It's ambiguous. In the case where the search string is empty, I'd simply do nothing:

private void btnReplace_Click(object sender, EventArgs e)
{
    if (txtSearchFor.Text.Length == 0) {
        txtReplacedWord.Text = txtInputWord.Text.Replace(
            txtSearchFor.Text, 
            txtReplaceWith.Text);
        txtReplacedWord.Visible = true;
    }
}
Narue 5,707 Bad Cop Team Colleague

The key piece of information is the location of select(): "/usr/include/sys/select.h". This is the POSIX version, which means it's being linked automatically and you need to rename your select() function to avoid conflicting with it.

Narue 5,707 Bad Cop Team Colleague

Can you tell me why use size_t and not int for orig_len and rep_len?

strlen() returns a value of type size_t. I like to use size_t for array sizing and indexing simply because it's a slightly better fit than int, and the standard library uses size_t extensively for that purpose.

Note that size_t is an unsigned type while int is signed, which has potential for subtle bugs if you mix them.

And what would i need to do so that the program would do the same if return type for function replace_str were void and not char?

You don't need to do anything, really. res is being passed as an argument, so it will be updated in the caller. Just modify the function a smidge to simplify things and you're done:

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

void replace_str(char *res, char *str, char *orig, char *rep)
{
    size_t orig_len = strlen(orig);
    size_t rep_len = strlen(rep);
 
    while (*str != '\0') {
        if (strncmp(str, orig, orig_len) != 0)
            *res++ = *str++;
        else {
            strncpy(res, rep, rep_len);
            str += orig_len;
            res += rep_len;
        }
    }
 
    *res = '\0';
}

int main(void)
{
    char res[BUFSIZ];
 
    replace_str(res, "thisisatest", "i", "foo");
    puts(res);
 
    return 0;
}

However, it is conventional to return a pointer to the beginning of the destination string rather than void in cases like this.

Narue 5,707 Bad Cop Team Colleague

Oracle Certified Java Programmer? Useless.

Indeed. For that certification all I got was a silly lapel pin. Nobody asks if I'm certified and takes it on faith that I know what the hell I'm doing from previous successful projects.

Narue 5,707 Bad Cop Team Colleague

gonna wiki you soon to see if your name comes up. After all you could judge kanetkar so easily then you must be someone like steve wozniak.

Unless someone wrote an article about me (I doubt it), you won't find anything on Wikipedia. However, you're welcome to visit my website or continue reading my posts on Daniweb and CBoard (under the user name Prelude) and judge for yourself if I know what I'm talking about. Be sure to wiki Kanetkar too, as pages dedicated to him are rather critical of his work. Fifteen years ago I'd be less critical, but since he's completely failed to update his books to keep with the times, I see no reason to be tolerant.

Narue 5,707 Bad Cop Team Colleague

Is 2n+constant a good big o notation for a sorting algorithm?

Yes, that's excellent relative to the usual suspects such as quicksort and mergesort, and it hints at the algorithm as well because comparison-based sorting algorithms have a hard bottom of Omega(nlogn). If you've dropped into linear territory your algorithm must be distribution-based similar to a bucket sort.

Narue 5,707 Bad Cop Team Colleague

What is Big O notation?

Big O Notation

Do you use it?

Yes.

I missed this university class I guess

Riiight. :icon_rolleyes:

Does anyone use it and give some real life examples of where they used it?

In many a code review I've used both time and space complexity with variants of Big-O to quickly prove that an algorithm won't scale as well as the application needs.

Narue 5,707 Bad Cop Team Colleague

Please confirm which name you wish to use, I can only give you one. :icon_rolleyes:

Narue 5,707 Bad Cop Team Colleague

But, I know that I won't be reading the standards... it's just mumbo jumbo to bring perfection and absolution in computing.

:|

And honestly, the explanation I gave works on major of my programs.

Oh joy, yet another ignorant amateur touting the tired old argument of "it works for me, so I'm right".

If I ever get a problem then I'll revise my ideas.

Well it's not just your problem, because you're trying to teach others. So when some tard's undefined behavior causes the plane you're riding to plow into a mountain because he listened to your advice, be sure to revise your ideas quickly. :icon_rolleyes:

Narue 5,707 Bad Cop Team Colleague

the game is from torrent, there's no patch available.
So I used the cd key from skidrow.

should I wait for a patch??

greetings

jeannot

Discussion of cracking is not allowed on Daniweb, nor can we in good conscience help with cracked software. Thread closed.

Narue 5,707 Bad Cop Team Colleague

string query = "select CAST(Fault_Time AS varchar(50)) then remaining query "

hope this work.

That's another alternative to try, but given that CONVERT() doesn't exist, I'd wager he's connected to a JET-SQL database. CAST() probably won't work any better.

Narue 5,707 Bad Cop Team Colleague

Maybe he doesn't know the code so he did the easiest thing to increase his posting.

I strongly doubt it. Walt is one of the better programmers on this forum.

Anyways here's the code.

And it doesn't solve the stated problem. But on the plus side, I can't scold you for giving away answers to obvious homework problems when your code is clearly unacceptable as a solution. :)

A book like "Yashwant Kanetkar Let Us C (Indian author)" will help for the basics alone!

A book is a good idea, but please recommend better books. Let Us C is utter crap.

Shorter and better algorithm means quicker execution and lesser memory.

Shorter and better are often mutually exclusive when it comes to algorithms. As an example, bubble sort is shorter, but quicksort is better.

Let's look at the code.

>#define SIZE 50 // Maximum length of sentence
That's a pretty short sentence.

>int main()
Kudos for using a correct definition of main().

>char s,temp[SIZE/2]; temp is unused.

>printf("\nInput string: ");
I never understood this whole newline at the beginning convention. It offers no benefits except a pointless blank line. A newline at the end makes more sense. Anyway, in this case you cannot guarantee that the prompt will be displayed before gets() blocks for input, so a call to fflush() is warranted:

printf("\nInput string: ");
fflush(stdout);

There are three times when the stream will be flushed:

  • When …
Narue 5,707 Bad Cop Team Colleague

Which way is the best to learn, Either to use Microsoft Visual C# or Notepad?

It's beneficial to learn how to invoke your tools manually rather than rely on an IDE like Visual Studio, but not required immediately. I'd suggest starting out with an IDE for ease of use, then dropping down to a command line process once you're more comfortable with the language.

There's nothing wrong with magic when first learning, but it's important that the magic is understood at some point, and the magic of an IDE is no exception. ;)

Narue 5,707 Bad Cop Team Colleague

Split to a new thread.

Narue 5,707 Bad Cop Team Colleague

There is no such thing as undefined behavior in C.

The language definition appears to disagree with you. Undefined behavior is stated as being behavior for which the standard imposes no requirements. The compiler writer is free to choose any result, reasonable or unreasonable, or even not choose a result and simply let whatever falls out of the compiler's design happen. So yes, there's most certainly a such a thing as undefined behavior in C.

It's programmers fault.

Yes, it's the programmer's fault for invoking undefined behavior.

You can sue the compiler maker for such problems!

Not successfully. As an analogy, you can't successfully sue the police for punishing you in a clear case of violating the law. Compiler vendors are not responsible for code compiled under their software that violates the rules of the language. Now if the code was compliant with the language standard and failed catastrophically, the compiler vendor could be sued because that falls under their contractual obligations.

Input two words and see that it prints only 1. This is because scanf was designed to take till \0 is encountered.

Incorrect. The %s specifier is defined as being whitespace delimited, so it reads until encountering any whitespace character. The two words are separated by whitespace in your example, and that's why only the first is converted by scanf().

The C standard library has all these defined.

Indeed. Maybe you should take some time to read the standard since you're clearly not familiar …

Narue 5,707 Bad Cop Team Colleague

What you need to do is debug your program. Step through it and check the indices. You can do this programmatically by adding debug checks at risky points if desired. For example:

void compare(int numberstocheck[], int n) 
{
  int i, j, k;
  int thebucket[n];
  for(i = 0; i < n; i++) {
    thebucket[i] = 0;
  }
 
  for(i = 0; i < n; i++) {
    int index = numberstocheck[i];

    if (index < 0 || index >= n) {
      printf("out of range at index numberstocheck[%d] with value %d\n", i, index);
      getchar();
    }

    thebucket[numberstocheck[i]]++;
  }

  for(i = 0, j = 0; i < n; i++) {
    for(k = thebucket[i]; k > 0; k--){
      if (j < 0 || j >= n) {
        printf("out of range at index numberstocheck[%d]\n", j);
        getchar();
      }

      numberstocheck[j++] = i;
    }
  }
}

Anywhere you have a potentially unbounded array index, check the index and display a debug message if it fails. Note that things like thebucket[i] are safe in a loop that's strictly controlled.

Mouche commented: Helpful advice for finding index overruns! +7
Narue 5,707 Bad Cop Team Colleague

Try CStr() instead of Convert():

string query = "select CStr(Fault_Time),[Level],[Trouble_Source],[Solution]," +
    "[Ticket_Status],[Close_Date],CStr(Close_Time),[Actual_Cause],[Solution]," +
    "[Description] from [TT_Record$]";

cmd = new OleDbCommand(query, conn);
Narue 5,707 Bad Cop Team Colleague

Let's start with the conceptually simpler one. var is something of a placeholder that says "deduce the type for me". Since the compiler already knows the type on the right hand side of an initialization, why should you be forced to specify it explicitly on the left hand side? Prior to the introduction of var , we had to do stuff like this:

Dictionary<string, MyClass> foo = new Dictionary<string, MyClass>();

Pretty redundant, no? With var , you can simply tell the compiler to deduce the type and only say it once:

var foo = new Dictionary<string, MyClass>();

The two definitions above are functionally identical. In both cases the type is statically defined as Dictionary<string, MyClass> . Now, this would be useful, but perhaps not so useful as to justify a new keyword. Another benefit of var is that it deduces types that you don't know, such as anonymous types (which are used heavily in LINQ):

var foo = new { a = "test", b = 123 };

dynamic is what everyone feared var was upon hearing about it. While var doesn't circumvent static type checking, dynamic does; dynamic is C#'s way of moving type checks from compile time to runtime. The intention is to simplify tasks such as interfacing COM, which has been notoriously tedious prior.

Narue 5,707 Bad Cop Team Colleague

Yeah, you can put safe estimations.. but doens't that happen that you cliets move to other programming companies because they offer faster and cheaper solution?

There's always going to be a company that's willing to undercut your estimate. The question is: are you willing to risk offering an unrealistic estimate just to win the client? Keep in mind that clients who only care about the lowest price are problem children more often than not.

Narue 5,707 Bad Cop Team Colleague

The problem is that the FillTime function doesnt calculate correctly.

Because you're passing it garbage. Rather than just give you the solution, I'll point you toward the root of the problem, which is a misunderstanding of pass by value vs. pass by reference.

Narue 5,707 Bad Cop Team Colleague

There's a Text property that supports both getting and setting:

s1Textbox->Text = gcnew String(ss.str().c_str());
Narue 5,707 Bad Cop Team Colleague

The few fake accounts that I have noticed all seem to have "Man" listed as their "Computer Specs and OS Flavor" and "Executive (C-level)" as their "Primary Role".

Two patterns that haven't been lost on us. ;) There are others as well, but I won't mention them so as to avoid helping the odd spammer who actually reads threads rather than posting to them.

Has anyone been analyzing data patterns in all the fake account entries? Or just looking for an uncommonly large number of posts?

At the risk of false positives, we've been using such patterns to ban new registrations before they ever post. Hopefully the attack isn't having as much of an effect on the community as the previous one due to proactive bans.

Narue 5,707 Bad Cop Team Colleague

The following code does not work.

Obviously. You're trying to print the return value of a function that returns void.

However, if you remove void in front of replace_str, in Code Blocks i am able to run it (WHY???) despite the fact that i still get a warning

Prior to C99, omitting the return type from a function causes the compiler to assume that you meant int. This is the implicit int rule, and the two following declarations are equivalent:

replace_str(char *res, char *str, char *orig, char *rep);
int replace_str(char *res, char *str, char *orig, char *rep);

It's not wise to rely on this rule though, as mentioned, it no longer exists in the latest revision of the C language.

Plus, i would like to know the correct sintax to print res using printf (the comment in code does not do it).

The bigger problem is that you're pointing res in replace_str() to a different place, not copying the contents of buffer into res . The code should be more like this (for replacing the first occurrence:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SIZE 1024

char *replace_str(char *res, char *str, char *orig, char *rep)
{
    char buffer[4096];
    int i;
    char *p;

    if (!(p=strstr(str, orig))) {
        for(i=*p; i<strlen(orig); i++)
            res[i]=str[i];
    } else {
        strncpy(buffer, str, p-str);
        buffer[p-str] = '\0';
        sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig));
        strcpy(res, buffer); /* Still unsafe... */
    }
    
    return res;
}

int main(void)
{
    char res[SIZE],s1[SIZE],s2[SIZE],s3[SIZE];
    
    scanf(" %s",s1);
    scanf(" %s",s2);
    scanf(" %s",s3);
    puts(replace_str(res, s1, s2, s3)); …
Narue 5,707 Bad Cop Team Colleague

Create a signature and post on forums that are relevant to your niche. It will take time and effort but it can be a strategy which can work.

There's a caveat to this approach: make sure your posts are relevant and useful to the forum. Otherwise you'll either 1) be tagged as a spammer and banned quite quickly or 2) viewed by the community as a prat who's only interested in selfishly promoting his website to the detriment of the forum. Both are frowned upon. ;)

Narue 5,707 Bad Cop Team Colleague

Here's a suggestion to handle threads that should be flagged as solved but haven't been.

Implement a control on the thread with the text "Notify OP to Mark as Solved".

Anyone (or perhaps anyone with a given minimum rep) can click on this control. This would cause an email to be sent to the OP requesting that he/she return to that thread and mark it as solved (perhaps there could even be a link in the email similar to the unsubscribe link that would accomplish this). To prevent multiple emails, the first click would also set a flag so that the control is disabled and replaced with the text "The OP has been notified to mark this thread as solved".

A special web page, available to moderators, could be created which cummarizes all threads for which the OP has been notified but for which no action by the OP has yet been taken.

The icons on the thread summary pages (new posts, popular thread, you have posted, etc) could be modified (perhaps displayed in red instead of purple) to indicate that a thread has been flagged for cleanup but not marked as solved.

This would put policing in the hands of the DaniWeb community and save the moderators (by virtue of the special web page) from having to scour the threads for cleanup. It would also ensure that OPs are notified that action is required.

It's a nice idea, but also a lot of work for a feature that's largely …

Narue 5,707 Bad Cop Team Colleague

You failed to give your structure a name. A typedef identifier is not the same as a structure tag, but you can use the same identifier for both because they're in different name spaces:

typedef struct node
{	char v;
	struct node *next;
}node;

This produces the usual C++ behavior:

struct node x; /* OK */
node x; /* Also OK */
Narue 5,707 Bad Cop Team Colleague
tabControl1.Region = new Region(new RectangleF(tabPage1.Left, tabPage1.Top, tabPage1.Width, tabPage1.Height));