Questions tagged as 'c'

1
answer

How can I copy the ASCII value to an int in C?

For example, having the following code my intention is to operate to obtain an index number #include <stdio.h> #include <string.h> int main(void) { char mes[2]= {"02"}; int numero; numero = (int)mes; char *strings[]={ "Ene",...
asked by 22.10.2017 / 06:19
1
answer

Data Structures (C)

Good morning. I was working with the code of a program and I have a doubt about the data structures. We have these two cases, one in the "programa.c" and another in the "programa.h": programa.c: struct _estructura { /* El código aqui...
asked by 05.02.2018 / 10:27
1
answer

syntax error near unexpected token 'while'

Programa que calcula el promedio de goles de un jugador por partido made by Bolanos Alfaro Jaime Sebastian include<stdio.h>//para los comandos printf, scanf y getchar int main(int argc, char *argv[ ]) {//abre funcion principal...
asked by 13.04.2017 / 01:00
1
answer

Reading of strings in C

I have a question regarding the reading of strings in C. I wrote this code and they corrected me the part where the text string is read. I previously had this written: scanf("%10000[^\n]\n",texto); and I think I did not really understand th...
asked by 03.10.2018 / 17:05
1
answer

Will not let me return true or false

I have to return true or false , but I get an error when I create the variable bool. How could I do? #include<stdio.h> main(){ int z[50], n, i, suma=0; bool verd = true; bool fals = false; printf("Ingres...
asked by 21.10.2016 / 23:46
1
answer

Problems with fscanf in C

Good evening, I have a problem using fscanf to read some data from an input file, the problem is that by no means read the file, this is the snippet of code FILE *infile = NULL; FILE *outfile=NULL; infile = fopen("mtbank.in", "r"); outfil...
asked by 01.10.2016 / 09:40
1
answer

Error "Operand of * must be a pointer" when creating pointer with malloc and using it in a FOR

I'm trying an example of the book "Understanding and using Pointers" that has this code: int main() { char *pc = (char*)malloc(6); for (int i = 0; i < 5; i++) { *pc[i] = 0; } return 0; } In theory, it should...
asked by 13.10.2016 / 17:48
1
answer

Error defining char

I have this simple code of a Header File and I get an error when defining this: typedef char Cadena[N]; and my code is this: /* cadenas.h */ #ifndef CADENAS_H_ #define CADENAS_H_ #include <stdio.h> #include <string.h> #de...
asked by 27.04.2016 / 18:48
3
answers

Enter the contents of a variable in file

How can I insert a string passed through a terminal into a file? fp=fopen("personas.txt","a"); printf("Introduce tu nombre:\n"); scanf("%s",&nombre); That is, what do I have to do to put the contents of the variable name in a file?    ...
asked by 18.05.2016 / 23:52
1
answer

Get distance between two declared points in a struct

I have a struct with different parameters, including one consisting of a point on a plane, with a coordinate x and another and . I want to create a function that, from two points, calculate its distance with the corresponding formula. My p...
asked by 16.05.2016 / 13:30