Click here to Skip to main content
15,617,116 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am supposed to identify the issue with the code fragment but without the full code I am having a problem identifying what the problem would be. I have gone through many blogs and added different code as suggested since I was getting a strcpy not declared error but with the code fragment as is I am not sure what the problem could be. I wish the assignment would give the entire code since the book is not much help. I understand this is a pointer for characters. This is a secure coding assignment and know that Microsoft has banned the strcpy function to strcpy_s. Thank you in advance for your assistance.

What I have tried:

void sampleFunc(char inStr[])
char buf[10];
Updated 3-Apr-21 17:30pm
Gerry Schmitz 2-Apr-21 0:12am    
I think you're supposed to try it; it just need something to call it; then you try the alternative. Compare. Or find something else to do.
KarstenK 2-Apr-21 4:45am    
Think about the instruction and its implication of every line. Write an example app and use the debugger memory view to look at the details.

But did you read all the documentation on strcpy() and really think about the code. You don't need the "full code". Everything you need is right in front of you. Pay attention to the input and the behavior of every line of code.
Share this answer
Your code fragment isn't complete: you need to use the code widget to engage the syntax highlighter (or paste it with the "Code block" option set) I suspect.

But while we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

So run it, look at it, and see what you can see that the user might do that would be outside of what he should be allowed!
Share this answer
I have added code to make it run and entered characters. I learned the input can be more than 8 characters but it will only display 8 on the screen that is the intended function. I am not trying to use the strcpy_s function and I am going through all blogs and posts. I spend hours reading and learning the concepts. I am not a programmer but trying to learn the basics for to complete my class. Below is my code where I am getting this error "strcpy_s’ was not declared in this scope" I will continue to research the issue.

#include <iostream>
#include <string.h>
using namespace std;

void sampleFunc(char inStr[])
char buf[10];
buf[9] ='\0';
cout <<"\n" <<buf<<"\n";
int="" main(){
char="" instr[10];
cout<<"enter="" string:="" ";

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900