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
________ returns the last character in a StringBuilder variable named strBuf? Select one: A. strBuf.charAt(strBuf.length() - 1)
Lunna [17]

Answer:

A

Explanation:

strBuf.charAt(strBuf.length() - 1)

4 0
3 years ago
Quick time and flash are two examples of what product
zheka24 [161]

there apps .........

8 0
3 years ago
A slide show is another name for a PowerPoint presentation. <br> a. True<br> b. False
ruslelena [56]
It is true because a powepoint is a projecter

8 0
3 years ago
Read 2 more answers
Please help!!!
Alchen [17]

The most probable reason why your code for the dog turning right instead of is because your conditional statements are not satisfied.

<h3>What is Debugging?</h3>

This refers to the identification and removal of errors in a given code or hardware component.

Hence, we can see that you should note that you are using teh ifElse conditional statement to execute your code and you stated that the dog would turn right if:

  1. The left side is blocked
  2. If there are balls present.

Therefore, there are balls present and also the left side is blocked which causes your dog to turn right because it is executing the else statement.

Read more about debugging here:

brainly.com/question/16813327

#SPJ1

6 0
2 years ago
Se tiene un pilar de hormigón de 30 cm de lado y 5 m de altura. Presenta una densidad de 2400 kg/m3 y una resistencia a la compr
kakasveta [241]

Answer:

El pilar no podrá soportar una masa de 10 toneladas

Explanation:

La dimensión del pilar de hormigón se da de la siguiente manera;

La longitud del lado, s = 30 cm = 0,3 m

La altura del pilar, h = 5 m

La densidad del pilar, ρ = 2,400 kg / m³

La resistencia a la compresión del pilar, σ = 500 kg / m²

El área de la sección transversal del pilar, A = s² = 0.3 m × 0.3 m = 0.09 m²

La masa del pilar, m = ρ × A × h = 2,400 × 0.09 × 5 = 1,080

La masa del pilar, m = 1.080 kg

Tenemos;

\sigma = \dfrac{F}{A}

Dónde;

F = La carga aplicada

A = El área de la sección transversal

∴ F = A × σ

F = 0,09 m² × 500 kg / m² = 45 kg

Por tanto, la carga que el pilar puede soportar sin compresión = 45 kg <10 toneladas = 9.071,847 kg

El pilar no podrá soportar una masa de 10 toneladas.

6 0
2 years ago
Other questions:
  • True or false? It is just too challenging to have different password for every
    12·1 answer
  • Type the correct answer in the box. Spell the word correctly. What aspect should you consider before adding pictures to a docume
    7·2 answers
  • In doing a load of clothes, a clothes drier uses 18 A of current at 240 V for 59 min. A personal computer, in contrast, uses 3.0
    7·1 answer
  • The company currently runs 60 autonomous APs and has plans to increase wireless density by 50% in the near future
    13·1 answer
  • bro this scared me, i thought i just got hacked, could someone explain why when i went to ask a question, it kicked me out my ac
    9·2 answers
  • What should you do to organize a large amount of data??
    10·1 answer
  • Does Buzz or APEX shows all your due assignments on the left of the main home screen?
    11·1 answer
  • Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar
    12·1 answer
  • Why is yo utu be down?<br> (You restrict talking about yo utu be, really)
    11·2 answers
  • for a given array of integers perform operations on the array return the resulting array after all operations have been applied
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!