[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: download (1).jpg (3 KB, 249x203)
3 KB
3 KB JPG
I heard when people use names others get pissed but I never saw it but I may be wrong but, im retarded about this shit because im a newfag but i am updating on the dorf fort ripoff. (pic is not from my version, i wish) The code is and its small enough I can just send a .cpp file you can look at it through a virus checker or whatever its safe I mean it is just a txt but idk people can sneak viruses into anything or maybe im just retarded.


Im new to c++ so this code will most likely be shit but im coming here just to ask for advice on how to improve with my code and stuff in c++ in general thats all idk if there are help threads so I hope i dont get banned or whatever, basically im making a dwarf fortress but flawless but Im shit at coding so im first coding the easy stuff so if you know how to improve the code i sent, better methods and that stuff in general. help. also my captcha was DAD8H4 lmao. FILE IS IN COMMENTS BECAUSE I WONT BOTHER WITH DOING CAPTCHA AGAIN AND AGAIN UNTIL THE FILE FUCKING WORKS
>>
File: download.jpg (11 KB, 245x206)
11 KB
11 KB JPG
#include <iostream>
#include <string>
#include <array>
#include <random>
#include <stdlib.h>
#include <time.h>


// Function to generate and print a random dwarf full name
void PrintRandomDwarfFullName() {
// Arrays of possible names
srand(time(NULL));
int number = rand() % 140;

std::array<std::string, 10> first_name_possibilities = {
"Anemisht", "Mossus", "Urist", "Yuanvioch",
"Constantine", "Hearn", "Easesa", "Elijah", "Tavi", "Octavian"
};

std::array<std::string, 10> last_name_possibilities = {
"Anemisht", "Mossus", "Urist", "Yuanvioch",
"Constantine", "Hearn", "Easesa", "Elijah", "Tavi", "Octavian"
};


// Random number generator setup
std::random_device dev; // Obtain a random seed from the hardware
std::default_random_engine gen{dev()}; // Create a random number generator with that seed




// Define the size of the arrays
auto first_name_size = first_name_possibilities.size();
auto last_name_size = last_name_possibilities.size();

// Create uniform distributions for the indices
std::uniform_int_distribution<int> dis_first_name(0, first_name_size - 1);
std::uniform_int_distribution<int> dis_last_name(0, last_name_size - 1);

// Generate random indices for first and last names
int first_name_index = dis_first_name(gen); // Random index for the first name
int last_name_index = dis_last_name(gen); // Random index for the last name

// Combine both names into a full name
std::string full_info = first_name_possibilities[first_name_index] + " " + last_name_possibilities[last_name_index] + " And the age is " + std::to_string(number);

std::cout << number << std::endl;


// Print the full name
std::cout << "Name: " << full_info << std::endl;
}

int main() {
PrintRandomDwarfFullName(); // Call the function to print the full name
return 0;
}
Thats odd, someone please find a way to upload .cpp or .txt to 4chan
>>
>>102419740
>im coming here just to ask for advice on how to improve with my code
>>>/g/dpt/
>>>/g/sqt/
>>102419754
 cout << "use the code tags" 

https://4chan.org/rules#g



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.