Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Data types
- #include <string>
- #include <cstring>
- #include <tchar.h>
- #include <cstdint>
- #include <cmath>
- #include <vector>
- //Streams
- #include <stdio.h>
- #include <cstdio>
- #include <iostream>
- #include <iomanip>
- #include <sstream>
- #include <fstream>
- char* readShader(char* filename) {
- FILE* infile;
- int tempint;
- tempint = fopen_s(&infile, filename, "r");
- if (tempint != 0) {
- std::cout << "Error " << tempint << " when reading file " << filename << std::endl;
- return "Error reading file.";
- }
- boolean loop = true;
- int loops = 0;
- char* text = "";
- char temptext[2];
- int index = 0;
- while (loop) {
- fgets(temptext, 2, infile);
- //std::cout << temptext;
- if (temptext != NULL && std::feof(infile) != 1) {
- //this next section is what causes errors
- if (loops == 0) {
- //strcpy_s(text, 2, temptext);
- text[0] = temptext[0];
- std::cout << text;
- }
- else {
- //strcat_s(text, 2, temptext);
- text[1] += temptext[1];
- std::cout << text;
- }
- loops++;
- }
- else {
- loop = false;
- }
- }
- fclose(infile);
- return text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement