Also posted here:
C Programming Linked List - C And C++ | Dream.In.Code
Type: Posts; User: thmm
Also posted here:
C Programming Linked List - C And C++ | Dream.In.Code
@laserlight,
I just wanted to show an alternative way to do certain things.
I don't claim that it is better.
Not needing inheritance is a just a nice side ffect.
I guess that not using virtual...
An alternative without virtual functions and pointers is to use std::variant and std::visit - since C++17.
#include <iostream>
#include <vector>
#include <variant>
class Vehicle
{
VS 2019 16.8.4 gives me this warning with /W4: warning C4189: 'i': local variable is initialized but not referenced
You probably need to enable Code Analysis on Build under Code Analysis in the...
That was my idea:
#include <stdio.h>#include <string.h>
void repeat(const char* input, char *output)
{
int n = 0;
char buffer[32] = {'\0'};
I don't think it has anything to do with the language, it has more to do about thinking clearly. Python would be easier to learn because you don't need manual memory management, it also has build-in...
@john.c
why do you mention books about C++ when he wants to learn C ?
I rather would do it like this:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <conio.h>
#include <string.h>
6356672 was the address of array1. If you want the actual number you have to use the subscript operator, like array1[0], array1[1]...
I would recommend that you get a (e)book. Just guessing how...
You need a format specifier in your printf.
printf("1+2= %d", int3);
You need to copy the values from arr1 to arr2 only if they are greater than threshold. There is no need to find the min.
Maybe sth. like this:
for (int i = 0; i < length; ++i) {
if...
You are right. Thanks for pointing it out.
Wouldn't it be possible to set the locale to a country that uses the comma as decimal separator and read the input as a flaot ?
When I ran the code in VS 2019 I got an exception at line 85
strcpy(A[index].name, temp.name);
when index was -307.
Have a look at this tutorial. It uses an int for the data but you could modify to use strings.
Given a linked list which is sorted, how will you insert in sorted way - GeeksforGeeks
Why not follow the KISS priciple?
#define NAME_LEN 100
char first_name[NAME_LEN];
scanf("%99s", first_name);
Consider sth. like this:
bool import(bool provided)
{
char file_name[256] = { 0 };
FILE* src = NULL;
if (provided)
Not sure if you have learned about functions yet, but they would make your task easier:
#include <stdio.h>
#include <stdbool.h>
void print_prime_factors(int num)
{
printf("The prime...
Still no luck with MinGW:
Alu_demo\alu\_.h|4|fatal error: unic/limits.h: No such file or directory|
It has nothing to do with MS. Neither MinGW nor cygwin have these
Is it really necessary to use non-standard headers like uchar.h and non-standard types like ssize_t ?
5. People might had an interest but couldn't build it Windows(possible)
If you want to do some automated testing - and at some point you need to learn it - you follow this pattern:
1. define your input
2. define the expected output
3. get the actual output
4. check...
Wheb hamster_nz spoke about heaps he porbbly meant the data structure, not the place where malloc allocates the memory.
Heap Data Structure - GeeksforGeeks
I am not sure if a text file is the...
Maybe like this:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int roll()
{
int dice;