Remove/Add nvidia drivers ubuntu 14.04.2
45
Firstly,
sudo apt-get remove --purge nvidia*
Enable the Universe and Multiverse repositories - you need to do this to allow the bumblebee and nvidia packages respectively to be installed. Then:
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic
sudo reboot
To run your application with the discrete NVIDIA card run in the terminal:
optirun [options] <application> [application-parameters]
Example:
optirun firefox
For a list of options for optirun run:
optirun --help
You can also use prime-select
option e.g.
sudo prime-select nvidia
sudo prime-select intel
To check:
prime-select --query
Related videos on Youtube
Author by
Natasha
Updated on September 18, 2022Comments
-
Natasha over 1 year
I'm trying to populate a blank 2d array (matrix) with a character
D
put onto a random position.This is the code which works properly:
#define RIGHE 10 #define COLONNE 10 void drawMap(char[][COLONNE]); int main() { char mappa[RIGHE][COLONNE] = {" "}; // blank, as an empty chess board drawMap(mappa); return 0; } /* Disegna la mappa da gioco */ void drawMap(char mappa[][COLONNE]) { int rigaDestinazione, colonnaDestinazione; srand(time(NULL)); // Randomizza numeri rigaDestinazione = rand() % RIGHE; colonnaDestinazione = rand() % COLONNE; mappa[rigaDestinazione][colonnaDestinazione] = 'D'; for (int i = 0; i < RIGHE; i++) { for (int j = 0; j < RIGHE; j++) { printf("[ %c ]", mappa[i][j]); } printf("\n"); } }
Unfortunately when I print it, it seems to be asymmetric as you can see, the output is:
[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ D ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
How can I fix?
-
Eraklon over 4 yearsSome quick solution:
if (mappa[i][j] != 0) printf("[ %c ]", mappa[i][j]); else printf("[ ]", mappa[i][j]);
-
-
Admin over 4 yearsWorks. Is there another solution without using string.h?
-
Ruslan over 4 years@anastaciu
sizeof(char)
is by definition 1, no need in this tautology. And it's better to let the compiler find out the size automatically by usingsizeof mappa
instead of doing the calculation manually. -
anastaciu over 4 years@ItsGhost, there is, like Ruslan said, in a loop, you can do it in the loop you already have.
-
anastaciu over 4 years@Ruslan, yes, sizeof(mappa) is better.
-
anastaciu over 4 years@ItsGhost, glad to help