can you use rand to read in from an external file inc++
C++
string line;
int random = 0;
int numOfLines = 0;
ifstream File("file.txt");
srand(time(0));
random = rand() % 50;
while(getline(File, line))
{
++numOfLines;
if(numOfLines == random)
{
cout << line;
}
}
Also in C++:
- Title
- c++ dereference a pointer
- Category
- C++
- Title
- C++ pointer arithmetic
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- 2d vector
- Category
- C++
- Title
- constant variables in c++
- Category
- C++
- Title
- fail() in c++
- Category
- C++
- Title
- RLE Encoding/Compression c++
- Category
- C++
- Title
- c++ code for polynomial addition
- Category
- C++
- Title
- visual studio 2019 read and write text file c++
- Category
- C++
- Title
- bfs in C++
- Category
- C++
- Title
- accept the noun and the output of plural c++
- Category
- C++
- Title
- vector initialization c++
- Category
- C++
- Title
- c++ create array
- Category
- C++
- Title
- min in vector c++
- Category
- C++
- Title
- fast io c++ geeksforgeeks
- Category
- C++
- Title
- how to print a 2d array in c++
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- correct sequence of compilation process in c++
- Category
- C++
- Title
- c++ char print fixed
- Category
- C++
- Title
- c++ vector
- Category
- C++
- Title
- factorial in c++
- Category
- C++
- Title
- cheap hosting
- Category
- C++
- Title
- sort function in vector c++ stl
- Category
- C++
- Title
- size of a matrix c++
- Category
- C++
- Title
- c++ assert
- Category
- C++
- Title
- c++ argv
- Category
- C++
- Title
- for each c++
- Category
- C++
- Title
- c++ char print align
- Category
- C++
- Title
- c++ vector constructors
- Category
- C++
- Title
- rick astley - never gonna give you up
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- c++ call method in same class
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- c++ sort array of ints
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- sum of vector c++
- Category
- C++
- Title
- basic ex of maps in c++
- Category
- C++
- Title
- gfg right view of tree
- Category
- C++
- Title
- get line C++
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- c++ rainbow text
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- how to output to console c++
- Category
- C++
- Title
- c++ string contains
- Category
- C++
- Title
- date to string c++
- Category
- C++
- Title
- time function c++
- Category
- C++
- Title
- empty string c++ value
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- c++ variable arguments
- Category
- C++
- Title
- what does map.count() return in c++
- Category
- C++
- Title
- clear file before writing c++
- Category
- C++
- Title
- class in c++
- Category
- C++
- Title
- c++ course
- Category
- C++
- Title
- c++ functions
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- c++ typeid get type name
- Category
- C++
- Title
- namespaces c++
- Category
- C++
- Title
- c++ smart pointer 2d array
- Category
- C++
- Title
- foind th output c++
- Category
- C++
- Title
- how to find absolute value in c++
- Category
- C++
- Title
- remove element by index from vector c++
- Category
- C++
- Title
- sub string of vector c++
- Category
- C++
- Title
- how to use assrt c++
- Category
- C++
- Title
- c++ compare char array
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- & in xml
- Category
- C++
- Title
- vector in c++ class
- Category
- C++
- Title
- c++ split at character
- Category
- C++
- Title
- gta san andreas
- Category
- C++
- Title
- map vs unordered_map in C++
- Category
- C++
- Title
- recursive in c++
- Category
- C++
- Title
- declare vectors c++
- Category
- C++
- Title
- int to float c++
- Category
- C++
- Title
- how to execute c++ program in cmd
- Category
- C++
- Title
- arduino for command
- Category
- C++
- Title
- how to find the index of an element in a vector c++
- Category
- C++
- Title
- if esle in c++
- Category
- C++
- Title
- what does the modularity mean in c++
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- how use global variables instead of local in c++
- Category
- C++
- Title
- print type cpp
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- add a timer c++
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- range of long long in c++
- Category
- C++
- Title
- log base e synthax c++
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- convert to lowercase c++
- Category
- C++
- Title
- max three values c++
- Category
- C++
- Title
- getch c++ library
- Category
- C++
- Title
- E/flutter (20384): [ERROR:flutter/third_party/txt/src/minikin/FontFamily.cpp(184)] Could not get cmap table size! E/flutter (20384): F/flutter (20384): [FATAL:flutter/third_party/txt/src/minikin/FontCollection.cpp(95)] nTypefaces == 0
- Category
- C++
- Title
- flake8 max line length
- Category
- C++
- Title
- c++ allocate dynamic with initial values
- Category
- C++
- Title
- newline in c++
- Category
- C++
- Title
- c++ ros subscriber
- Category
- C++
- Title
- rand c++
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- c++ files
- Category
- C++