• Register
1 vote
19 views

Problem:

How to run a program and print in c++. I hope you guys are not laughing at my question. Yeah, I am a newly born programmer laugh

#include <string>
string someString("This is a string.");
printf("%s\n", someString);

I tried this but it’s not working.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution:

Try 

#include <iostream>
std::cout << someString << "\n";

OR

printf("%s\n",someString.c_str());

 

13 9 6
94,240 points

Related questions

0 votes
1 answer 1 view
1 view
Problem: How to print elements in a vector c++?
asked 19 hours ago Supti 1.7k points
0 votes
1 answer 2 views
2 views
Problem: Hello, If any one help me then i will be greatful. I am interested in printing the structure fields . Typedef struct { UINT32 thread_id; BOOL is_valid; }T_THREAD; Is there a way in "C" language to print the contents of a structure, something like ex: print (T_THREAD) and output should be like Contents of a structure T_THREAD are thread_id is_valid
asked 3 days ago Yeamin 1.2k points
0 votes
1 answer 3 views
3 views
Problem: Guide me the way to print ascii value of a character in c.
asked 5 days ago zayed1 35.6k points
0 votes
1 answer 1 view
1 view
Problem: I need help in resolving this problem: how to print in binary in c
asked 6 days ago rakib1 51.5k points
0 votes
1 answer 1 view
1 view
Problem: Please help me to solve it out : how to print binary number in c
asked 6 days ago rakib1 51.5k points
0 votes
1 answer 2 views
2 views
Problem: Hello,I am looking for assistance with the following, "how to print out a vector in c++" is there someone who can assist me?
asked Apr 8 sumaiya simi 16.2k points
1 vote
1 answer 2 views
2 views
Problem: Please help me. How can I solve it? how to print quotation marks in c
asked Apr 7 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 5 views
5 views
please let me know the problems of how to print float value in c upto 1 decimal places ?
asked Apr 6 ashik 12.9k points
0 votes
1 answer 16 views
16 views
The program works up to 3 for but from the fourth the search for the minor / s and the major / s begins, which I managed, but if the value is repeated (which is the lowest or highest ), thus having 2 (or more) minors or majors, it only prints the one below the entered ones. So the question is ... << << "is the one with the fewest days left" << "(" << less << ")" << endl; cout << endl; return 0; }
asked Aug 14, 2020 game 4.6k points
0 votes
1 answer 12 views
12 views
I have a program, I would like what is printed to be Uppercase regardless of what it receives (MAYUS or minus). It is almost ready, I just need to print in capital letters. I print my void in the main, but I want it to print my void in UPPERCASE. Example Hello World. (with offset 3) KROD PXQGR #include ... if (secret [i] == alphabet [j] && j <78) { secret [i] = alphabet [j + n]; j = 52; } } } } }
asked Aug 10, 2020 game 4.6k points