prinf and scanf will not work in c++ .please share with complete solution cout and cin usage in c++
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 3:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 4:10 AM
Why? printf and scanf work great in c++. # include <cstdio>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 4:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 4:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 12:57 PM
You cannot use a C++ include file in a plain C file. main.c is a plain C file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 7:00 PM
i made stdio.h in main.c and tested find that printf is working.
i made cstdio in main.cpp and tested find that prinf is not working .
i need to change the setting in properties -> c\c++ build-> setting -> g++compile>preprocessor is so please suggest an exact setting screen shot .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-25 7:58 PM
> i need to change the setting in properties -> c\c++ build-> setting ->
This works for me with libraries provided in CubeIDE and your PUTCHAR_PROTOTYPE above, without any changes in settings:
// File: testcpp.cpp
#include <cstdio>
// call this from your main.c
extern "C"
void test_cpp(void)
{
printf("hello c++ %d\n", 42);
}
Getting a bit fancier.... the following works too, with language standard ISO C++17:
#include <cstdio>
using std::printf;
extern "C"
void test_cpp(void)
{
printf("hello c++ %d\n", 42);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-26 6:13 AM
Use printo("text", double, float, uint(8-16-32-64)_t, int(8-16-32-64)_t ). Any parameters without restrictions, in any order.
https://github.com/AVI-crak/Rtos_cortex/blob/master/sPrint.h
Before using, define the string output function - soft_print(char* txt)
Works very fast.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-26 11:26 PM
- hi , pavel , i am facing difficulty and error where i need keep this /
now kept in
/* USER CODE BEGIN PFP */
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}
void test_cpp(void);
/* USER CODE END PFP */
/* USER CODE BEGIN 4 */
- extern "C"
- void test_cpp(void)
- {
- printf("hello c++ %d\n", 42);
- }
- /* USER CODE BEGIN 4 */
while (1)
- and try call by test_cpp(); in loop .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-27 2:24 AM
hi pavel, i was try with many times . since it's working with you can share exact location i need keep and calling .
