Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to print a variable inside double quote.

0 votes
asked Apr 11, 2020 by panneer selvam (120 points)
print variable inside double quotes(" variable ");

ex:

int main()

char a[] a="data;

char arr[]="the value is=a";

printf("%s",arr);

output= (the value is=data) <- this is what print in output window.

anyone ??

1 Answer

0 votes
answered Apr 27, 2020 by chn (240 points)

 First option:

#include <iostream>
#include <string>
#include <iomanip>
int main()
{
    std::cout << std::quoted("abcd");
    return 0;
}

Other option with exception character "\":

std::cout << "\"\"";

Another option with raw string:

std::cout << R"("example")";

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...