1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dybincka [34]
3 years ago
14

I have a real struggle when it comes to working with strings, whether they're arrays or pointers to strings, and I'm lost cause

when I read or watch tutos I understand them, but then I'm like a novice when I need to write actual code, what should I do?
PS: I'm using C language.
Computers and Technology
1 answer:
neonofarm [45]3 years ago
6 0
In C, you deal with a string always via a pointer. The pointer by itself will not allocate memory for you, so you'll have to take care of that.

When you write char* s = "Hello world"; s will point to a "Hello world" buffer compiled into your code, called a string literal.

If you want to make a copy of that string, you'll have to provide a buffer, either through a char array or a malloc'ed bit of memory:

char myCopy[100];
strcpy(myCopy, s);

or 

char *myCopy;
myCopy = (char*)malloc( strlen(s) + 1 );
strcpy(myCopy, s);

The malloc'ed memory will have to be returned to the runtime at some point, otherwise you have a memory leak. The char array will live on the stack, and will be automatically discarded.

Not sure what else to write here to help you...
You might be interested in
What would happen if the two pith balls shown in the figure above were held together for a few moments, then released?
Arisa [49]

B. The charge would leak off and the pith balls would hang straight down.

3 0
3 years ago
Linotype is similar to letterpress since both utilize lead type. The difference is that in a linotype, the type is cast into ful
Maru [420]

Answer:

I think it would be.

A-Metal-cast pouring system

<h2>I hope it helps</h2>

8 0
4 years ago
A + B (AC (B +C’) D) = A + BD
zmey [24]
Yo what is that i’m confused
5 0
3 years ago
Read 2 more answers
The sections that should be included in your research paper are the _____.
Fiesta28 [93]

Thesis

Intro

Body

Conclusion

5 0
3 years ago
Virtual reality simulates a three-dimensional environment with which users can explore and interact. True or false?.
Damm [24]

Main Answer:

Virtual reality simulates a three-dimensional environment with which users can explore and interact. True.

Sub heading:

what is three dimensional?

Explanation:

1.Three-dimensional space is a geometric setting in which three values are required to determine the position of an element.

2.This is the informal meaning of the term dimension.

3.In mathematics, a tuple of n numbers can be understood as the Cartesian coordinates of a location in a n-dimensional Euclidean space.

Reference link:

https://brainly.com

Hashtag:

#SPJ4

4 0
2 years ago
Other questions:
  • To specify grouping and sorting for a report, click the ____ button on the design tab in layout view.
    14·1 answer
  • In a spreadsheet, equations that use addition, subtraction, multiplication, and division operators, as well as values and cell r
    9·1 answer
  • In order for Dr. Reynolds to send a CPOE from her office computer system to the computer system at the local hospital, a/an ____
    5·1 answer
  • Each tab is divided into groups of related commands or buttons. T or F
    10·1 answer
  • Manuel is working on a project in Visual Studio. He wants to keep this program showing on the entire desktop, but he also needs
    13·1 answer
  • When you set up a worksheet, you should use cell references in formulas whenever possible, rather than ____ values.
    11·1 answer
  • Which of the following is a benefit, as well as a risk, associated with peer-to-peer networks?
    6·2 answers
  • The _____ of a local variable is the function in which the variable is created.
    6·1 answer
  • A major retailer wants to enhance their customer experience and reduce losses
    6·1 answer
  • Can i have help for a ggogle class room
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!