Category : buffer

My program is taking string input from the user using fgets() function and I had also tried gets(), scanf("%[^n]s", str) function but still program get terminated at half. Book* create_book() { Book* new_book; char* title; char* author; char* publisher; double price; int stock; printf("nPublisher: "); fgets(publisher, 50, stdin); printf("nTitle: "); fgets(title, 50, stdin); printf("nAuthor: "); ..

Read more

I`m trying to create opengl triangle and I bumped up with some problem. EBO : ElementArrayBufferObject VAO : VertexArrayObject while i trying to binding EBO before binding VAO it causing error and i don`t know why. my code : // Generate the VAO and VBO with only 1 object each glGenVertexArrays(1, &VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, ..

Read more

This is my code for read a data from file: void sendfile(string pathname) { ifstream ifs(pathname, std::ifstream::in); if(ifs.fail()) { throw "error opening"; } const size_t BUFFER_SIZE = 1024; char* buffer; buffer = new char[BUFFER_SIZE]; // get file size ifs.seekg(0, ios::end); int file_size = ifs.tellg(); ifs.seekg(0, ios::beg); cout <<"File size : "<<file_size<< "bytes"<<endl; unsigned char *data ..

Read more