i'm making this function that replaces single slashes in a path with doubles slashes. It works for everything but slashes because I gotta use doubleslashes to specify a single slash so how do I refer to double slashes.

QString AddDoubleSlashtoPath(QString Path){
    QStringList splitup=Path.split("//") ;/*supposed to be a single slash*/
    QString newString;
    int currentStr=0;
    int stopP=splitup.size();
    while(currentStr!=stopP){
        newString.append(splitup.at(currentStr));
        if(currentStr!=stopP-1)
        newString.append("//");/*where I actually need doubleslashes */
        currentStr++;
    }
    return newString;
}

newString.append("//");/*where I actually need doubleslashes */

Do the same thing twice:

newString.append("////");/*where I actually need doubleslashes */

The double slash in string literals is an escaping measure because a single slash represents the starter for an escape character. Thus the escape character for a single slash is two: one to introduce an escape character, and the other to act as the value of the escape character. You can have as many of those escape characters as you want, but it can get confusing when there are just rows of slashes. ;)

wow thx, that solves some other problems i been having too

Double backslash in strings is equivalent to a single forward slash if your talking about paths.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.