Posts by arfneto • 1,196 points
87 posts
-
0
votes2
answers152
viewsA: Ordering values by pointers
"I wanted to know if I was wrong about using the pointers or my mistake was in logic". Certainly in the use of pointers, or in the non-use in the comparisons. And the logic I have not yet…
-
0
votes1
answer58
viewsA: How do you transform a Class from c++ to c?
I’m needing to turn a code into c++ for c (I know, backward), I’ve already transformed the prototypes part of the functions, which would be the .h. file. c he calls this class separated with :: What…
-
1
votes2
answers185
viewsA: Fraction Sum Program (Class Overload)
Good evening, I have a question in my program of sum of two fractions using overload of classes, in which the program it is always printing the same value, even modifying the parameters of the two…
-
0
votes2
answers148
viewsA: save Fibonacci sequence in C
Your program is not good. Have a book about C? Thought about it? Read some table sore the sequence? Had you thought about it and looked for a table and would you see for example in The first 100…
-
-1
votes1
answer34
viewsA: How to print a dynamic list in c++?
I couldn’t understand what you tried to do or even ask. In the code below it seems that you are using the list methods provided by the language... { Lista lista; lista.push_front('a');…
-
0
votes1
answer40
viewsA: How to pass string to an insert function
You wrote: Lista* Nlst=(Lista*)malloc(sizeof(Lista)); Nlst->nome; Nlst->idade=id; Nlst->prox=lst; return Nlst; And probably intended to write Lista* Nlst=(Lista*)malloc(sizeof(Lista));…
-
1
votes1
answer41
viewsA: Dynamic allocation and use of C pointers
Avoid returning void. In general it’s a waste, often a mistake. The printf() of a float does not use & and that’s a mistake. It lacked to follow the indices of the highest and lowest value. And…
-
0
votes2
answers46
viewsA: Implementation of member functions
Is it wrong to define member functions within the class itself? Or is it just a matter of code organization to write the prototypes in the class creation and then implement them? In general it is…
-
0
votes2
answers512
viewsA: Chained List in C Language print inverse list
I changed the original example a little bit because I had posted wrong and to show the lack it makes Lista not to be a complete structure, but only one knot. I will leave an example at the end with…
-
0
votes1
answer77
viewsA: Data Structure, Dynamic Memory Allocation in C++ and Data Reading
In my code I have to display objects in a static way but I want create them dynamically. I have a class called worker that has 2 objects from other 2 classes (info and family) like yours members, so…
-
0
votes1
answer49
viewsA: Code does not execute instruction correctly in C++
I have a code on main that works normally. Maybe it doesn’t work that normally. Why does this happen? The short answer is that you missed the statement of the builders of info and familia and…
-
1
votes1
answer154
viewsA: Error inserting elements into a vector - C++
If you really need the functions as declared and the data in this format, I think the simple is to use fscanf() to consume the input and create the two vectors, more or less as did. However how you…
-
0
votes2
answers63
viewsA: Segmentation failure when printing white space C
I need to do a function that returns a doorman to the first blank space found in the string. When I try to print the blank space program shows segmentation failure, which does not happens when I…
-
2
votes2
answers149
viewsA: String-populated chained list(Linked list)
This is a node from your list: typedef struct tipoNo { char* info; struct tipoNo* prox; } no; And it shouldn’t be your list. A linked list is a collection of nodes and not a node. Every time you use…
-
0
votes1
answer79
viewsA: Error in Structure Memory Allocation
struct Aluno { int matricula; int *nota; }; This is the structure Student, but it seems to be also his registration to be judged by the statements in main() struct Aluno *cadastro; struct Aluno…
-
0
votes1
answer56
viewsA: How to see if a string has numbers
Ana, One letter is one letter string. Use something to read the whole line, like getline(). Still on your program, note that no need to rewrite isdigit() because it is available in C++. You may have…
-
3
votes2
answers95
viewsA: How to print a class in c++?
How to print a class in c++ is something very generic. I’ll show you a common example, and also show why what you tried to write doesn’t work, although it’s already clear in the @Maniero reply Its…
-
0
votes2
answers161
viewsA: Terminate program with enter/ EOF
do{ scanf("%d %d", &n1, &n2); sum = n1 + n2; printf("%d\n", sum); }while((scanf("%d %d", &n1, &n2) != '\n')); Do you have a book about C? a manual? Read something about scanf()? You…
-
0
votes1
answer34
viewsA: Allocate Attribute Memory in Structure
Post a whole program so that someone can easily test it if they think it can help you. struct Aluno { int matricula; int nota; }; void cadastraNotas(struct Aluno* cadastro, int aluno, int *qtdNotas)…
-
1
votes1
answer80
viewsA: c what is the error of this code
gin, Your program has minor problems with declarations, things your compiler might have shown, like preco float; instead of float preco; in the statement scanf() to read color, a char[100], using…
-
0
votes1
answer36
viewsA: Segmentation Fault when running pop command on dynamic stack
I changed your code a little to show you what I was talking about Its structure typedef char pilha_item; struct pilha_no_struct { pilha_item item; struct pilha_no_struct* prox; }; typedef struct…
-
6
votes3
answers138
viewsA: Why does the Endl exist in C++ and n already performs the same procedure?
std::endl; force a flush on the way out. cout is not the only possible way out of streams and in many cases it may be important to ensure flush() at the same time to be sure that the data was…
-
0
votes2
answers55
viewsA: Resume part of a string in function Return
i want to take information that is variable, and always comes after the word "data", e.g. Let’s say my string contains "data:HS73NSS9374N7ALW823", so I’m trying to develop a function that identifies…
-
0
votes2
answers478
viewsA: Search in file . txt
Your program looks very complicated without need. Write your program around the data. Always. In general, when asked for this type of solution for a student, he has already learned about structures,…
-
0
votes3
answers80
viewsA: Do I need to re-allocate a structure in case I clean up just a part of it?
typedef struct { char nome[20]; char data[20]; } Dados; Dados *dados_cliente[quantidade]; The name and date in its structure are strings, 20 bytes terminated by null. "Cleanse" a field like this can…
-
1
votes2
answers58
viewsA: How to access vectors of a class in C++
I could explain something else about these things that I don’t understand? The program works when I separate into parts And what would that separation look like? You can post a code like this? But…
-
1
votes3
answers138
viewsA: The main function and its arguments. How does it manage to assign to its argc and *argv[] arguments the parameters passed via terminal?
The short answer is yes. You can do this. And as you can imagine, it’s a very common need. By coincidence I posted a program yesterday on this site that does exactly that, and the link is this: for…
-
0
votes2
answers498
viewsA: How to delete the terminal from what was written when running a C program?
Use system() to do something is not actually doing something in a program. And it is something condemned or prohibited in many places for security reasons. It’s like someone asking you the way to a…
-
1
votes2
answers2230
viewsA: setlocale(LC_ALL, "English"); does not work in Visual Studio 2019
There is nothing in upgrading to Windows 10 that will create accent issues. In fact since 2018 Windows 10 has the Terminal which is the right place to run console programs since then: accents,…
-
0
votes2
answers1247
viewsA: How to check if one or more string has uppercase/lowercase initial character (C Language)
Your show is really complicated, and I really don’t get it. You can use something simple like int inicial_minuscula(const char* str) { return (((*str) >= 'a') && ((*str) <= 'z')); };…
-
0
votes1
answer70
viewsA: 5% URI error (in C language)
The limit for money in the statement is one million so it fits in one int. More importantly, a hundred million fits into one int. Then multiply all values by 100 and use int and everything is right.…
-
0
votes2
answers72
viewsA: There is some difference between these two ways of Bubble Sort°
There are authors who call the first version "optimized". But one might call the latter "dumb" or at least "naive" --- to be politically correct. If you’re going to be sorting the giant vector there…
-
2
votes1
answer184
views -
0
votes1
answer122
viewsA: Bubblesort reading and sorting of csv file in C
Managed to finish? The first part is to define an array of these structures and load the whole file into memory, a record in each structure. The simplest is to create a vector of pointers for…
-
0
votes2
answers342
viewsA: Error exited, Segmentation fault in C
I still have one precise question that my test will remember more than one date, you know how I can do that? since even using it as vector it is not yet saving I tried to guess what you intend to do…
-
0
votes3
answers1148
viewsA: Dynamic allocation in C - allocating without knowing the total amount of elements
You’re right, but you’re wrong ;) When you allocate memory you have to know how much it will allocate, it is the parameter for malloc(): the number of bytes. But you are perhaps summarizing the…
-
1
votes2
answers231
views