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
A set of programs that enable the hardware to process data is _____.
Mnenie [13.5K]
The most appropriate answer is C !! software os used for using hardware !!
4 0
3 years ago
Which components are involved with input? Output? Processing? Storage?
VMariaS [17]

Answer: Output

input keyboard mouse joystick graphics tablet trackball touchpad touchscreen microphone sensor      

Processing     processor (CPU) processor (GPU) memory motherboard

Output printer monitor touchscreen plotter speakers headphones motor data projector

Explanation:

5 0
2 years ago
Read 2 more answers
What is a data source in OLE?​
babunello [35]

Answer:

OLE DB Driver for SQL Server uses the term data source for the set of OLE DB interfaces used to establish a link to a data store, such as SQL Server. Creating an instance of the data source object of the provider is the first task of an OLE DB Driver for SQL Server consumer.

Explanation:

hope it helps you and give me a brainliest

6 0
1 year ago
The force that pulls away from a curve is known as
77julia77 [94]

The correct answer is centrifugal force.

The force that pulls out from the center on a body that is in a circular motion is called centrifugal force. This force increases as the speed of motion increases. It is centrifugal force that results in a strong outward pull on your vehicle traveling around a corner.

7 0
3 years ago
Match the Job description with the job titles.
koban [17]
1) Bricklayer 2) Roofer 3) Architectural drafter 4) landscape architect
6 0
1 year ago
Read 2 more answers
Other questions:
  • What is the recommended size for bulleted text?
    5·2 answers
  • While in an interactive nslookup session, you'd use the ______ keyword to change the DNS server you're using
    5·2 answers
  • what type of authentication does the dod require to accesss sensitive data on mobile devices and /or email
    7·2 answers
  • The ____ cell on the worksheet is the one into which you can enter data.â
    15·2 answers
  • Forensic computer investigators must _____.
    6·2 answers
  • Which four of the following hardware components are specifically used to enable networking and are not part of a stand-alone com
    13·2 answers
  • Once secured a wheelchair may move up to 6 inches in any direction
    6·1 answer
  • "The ability to assign system policies, deploy software, and assign permissions and rights to users of network resources in a ce
    7·1 answer
  • Why is local hosting not suitable for a public website?
    15·1 answer
  • In Super Mario Bros., you become Mario and your friend is Mario’s younger brother Luigi. Your job is to race through Mushroom Ki
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!