c

c

How do I store a string of undefined length in a structure?

Question: #include <stdio.h> #include <stdlib.h> #include <string.h> struct Ecoponto{ int codigo; int contentores[3]; char cidade[20]; char *rua; int nporta; }; int main(int argc, char** argv) { struct Ecoponto ecoponto; printf(“\nIntroduza o nome da rua:”); scanf(“%s”,ecoponto.rua); printf(“%s”,&ecoponto.rua); return (EXIT_SUCCESS); } I would like to know the best way to store "the …

How do I store a string of undefined length in a structure? Read More »

When I execute a C language string copy in visual studio, the strcpy part becomes an error.

Question: Question: I'm sorry if there is a shortage etc. for the first time posting here. Can you tell me the reason for the error? #include “pch.h” #include <iostream> #include <string.h> #include <stdio.h> int main(void) { char str[10]; **strcpy (str, “MARIO”);** printf(“%s\n”, str); return 0; } thank you for your …

When I execute a C language string copy in visual studio, the strcpy part becomes an error. Read More »

Scroll to Top