strncpy_s

Here is a portion of my code, im trying to string copy my description (from my main.cpp) to my name char variable, im getting an error under strncpy_s that says:

no instance of overloaded function "strncpy_s" matches the argument list
argument types are: (const char *, char *)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#include <iostream>
#include <iomanip>
#include "item.h"
#include <cstring>
using namespace std;
using namespace items;
char*  name;
double itemprice;

void item::set(const char* description, double item_price)
{
	itemprice = item_price;

	strncpy_s(description, name);

}
	


void item::display(int n) const
{
	
		cout.width(10);
		cout.fill('-');
		cout.setf(ios::left);
		cout << name;
		 
		cout.width(7);
		cout.precision(2);
		cout << itemprice << endl;
	


	
	

}
Last edited on
I would guess that you want to use strncpy_s() (whithout the n).
strncpy[_s] requires an additionally parameter count
same issue.
no instance of overloaded function "strcpy_s" matches the argument list
argument types are: (const char *, char *)
Any thoughts guys? ;-;
Do not use any *_s functions. They are not part of the standard and are mainly MS extension. DIfferent compilers define them in different way. You can just use strcpy here.
And when using strcpy, the destination is the first argument:
strcpy(name, description);
Topic archived. No new replies allowed.