Questions tagged as 'c'

1
answer

Search for item [List]

I want to search an element of a list by a name (vector of characters). I get the name (espm) in function and childbirth for the search. The problem is that the function always tells me "There is no doctor with this specialty" even when the na...
asked by 23.08.2016 / 02:46
1
answer

Function to sum elements of a vector does not return correct value

I am making a program for a shopping list, the user passes the values of each product to the program and each one is stored in a vector. Then I add the elements of the vector to give the total value of the purchase, on that I created a function:...
asked by 20.08.2016 / 19:52
1
answer

Queue implementation in ANSI C

I have a code (end of question) that allows the handling of a queue in ANSI C , my question is as follows: The code declares a data type itself to store the queue data and has a function to create a queue, however it uses in the integer exampl...
asked by 18.08.2016 / 22:47
1
answer

Increase the reliability of random numbers

I have a function that generates pseudo-random numbers with rand that has a seed that is a publicly known time. Changing seed is not an option. The application needs a more accurate degree of randomness because it sorts a sequence...
asked by 02.10.2015 / 02:46
1
answer

Repeat commands to restrict a valid value

I need a code that reads a number greater than 1, and if a number less than or equal to zero is entered, another number is requested, and can therefore be tested if true. I would like help completing my code. #include <stdio.h> int m...
asked by 06.09.2015 / 05:05
1
answer

Problem in the search function

I am not discovering the problem that is in my function, it does the following: I get a char array with '\n' at the end. Then I go through the vector verifying: If you find in the vector the exclamation mark, end point, or questio...
asked by 11.06.2015 / 02:42
3
answers

How to read the first three characters of a string?

I have an application in C. It already opens a text file and reads the entire line that the file has. It's a long line, for example: HTJxxxxxxxxxxxxxxxxxxxx ... I can store this text file's contents in a variable. But how do I read the fir...
asked by 08.06.2015 / 05:49
1
answer

Difference between cast of structures

struct a{ int a; int b; }; struct b{ int a; int b; } int main() { struct a *p; struct b b; p = (struct a *)b; // deste modo da erro p = (struct a *)&b; ; deste modo o compilador não aponta erro; } Would you li...
asked by 31.01.2016 / 22:09
1
answer

How to get really random numbers with 'rand ()' in C?

For school work, I need to create a game, for which I need to generate a random number to make it fair. In one case, as I'll post below, I need to designate a random number between 0 and 2 to modify in the string: int NUM, AUX; char PORTAS [0]...
asked by 21.11.2015 / 20:20
1
answer

Switch large case in C

I am developing a system for college and would like to know the best option, in the sense of code optimization, even improvement. I have switch case for Menu, where I have 88 cases. I have a screen called "Help", in this screen, the...
asked by 11.11.2015 / 14:25