So for a project, my professor sent out two pages of code containing functions to read a text file (since we do not know how to write this on our own yet). I've got the code working on Orwell IDE and it gives me 2 warnings saying
"Passing argument 1 of 'readFromFile' from incompatible pointer type"
"Passing argument 2 of 'option2Print' makes integer from pointer without a cast"
The Orwell IDE seems to just bypass these warnings and compiles the code correctly. However, when I transferred my files over to my desktop using BloodShed (what the professor uses), instead of getting a warning I get an error and the code won't compile.
I assume it will not compile on his computer either since he uses the BloodShed IDE.
I don't know how to put the code directly into the text neatly, so a attached a .zip file with my code. The "storms.txt" file is also included. (the file that will be read).
error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*' error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*'
These errors are related to " *ptr->character='a'; printf("Ptr: %c",*ptr->character); "
I want to access "character" data inside the structure "trial" by a pointer to pointer "ptr" inside function "function",but I couldn't find a way to do this.
I am having a structure called matrix as shown below to represent a matrix your read from a text file.
struct matrix { double mat[30][30]; //content of the matrix mat int row; //number of row in the matrix mat int col; ////number of col in the matrix mat };
Declare 3 variables of structure matrix, m1, m2 and m3 in main to be used as describe below.
Task:
1.Write a function void readFile(char *filename, matrix *m) that will read a matrix from a text file and copy to the structure matrix m.
I am trying to use struct to store variables from a text file and use them in the main program. I have first tried running the program without using struct and declaring the variables within the main program and it runs fine. But after using struct, it gives no compilation error and a segmentation fault as output. Also, if the size of file/variable size is unknown can I declare variables as char string[]??
The code is as below:
Code:
#include<stdio.h> struct test { char string1[10000];
I need to create certain objects which are listed in a file. So my code needs to run a loop and create objects(of type specified in file) and put them in a list.
It appears to me that type specifiers can't be replaced by string. Is there a way out ? I want following code to be working somehow.
#include <iostream> #include <string> using namespace std;
I'm working on a program where I have a vector full of <myClassType> structs.
I'm trying to insert items into a vector, searching first through the vector to make sure the value isn't already in the vector before inserting it. The "find" function isn't working properly.
I keep getting C2678 "binary '==': no operator found which takes a left-hand operand of type "myClassType" or there is no conversion errors in Visual Studio 2010.
I know it's something having to do with the find function and my iterators, but I can't, for the life of me, figure out what it is.
I've tried switching to const_iterators, but I get the same error message.
I am trying to make a automated menu. It shows there are no syntax errors but when compiled it says cannot convert choice from type into to menuItemType. I am not sure what I did wrong. Here is the code
class T { enum E { } struct S { } interface I { } delegate void D(); class C { } }
[code]....
All of the above are possible except the constant field of a type that is a struct. I can see why the non-string reference types would default to the only literal expression they can represent - null - and if I'm not mistaken the default value of a struct is an instance of the struct with all its fields set to their default value, but why is it that a const struct field is not possible? is there a reason why or is it just the way c# was written? oh and by the way, what's the idea of allowing enum types to have a default constructor?
I am trying to compile the files below. The PosLin.cpp contains the SurTriAuto and SurTriPosRotAndQ functions below. Before adding SurTriPosRotAndQ, it compiled fine, but when I added SurTriPosRotAndQ, I am getting "invalid use of incomplete type ‘struct PosRotAndQ" error messages
I was thinking I could try moving SurTriAuto and SurTriPosRotAndQ to PosLin.h, but since they return "T*", I'm not sure what to do
I have a "t.h" file
namespace TNS { class T {
[Code]....
when I add "include Pos/PL.h" to geopar.h, I get an error saying v.hpp is missing, where v.hpp is part of a 3rd-party software and it is already in my directory
I've been reading the tutorials on Friendship and Inheritance [URL] ..... but I still don't understand why I can't access members of the same struct type.
The code above is located in a source file, where the function isAlphanumeric passes a char value, and Message is the struct containing the string I want to access. Below is the declaration of the struct and string located in the corresponding header file.
My frustration comes when I try to call and assign messageText like the tutorial does to its private members, but I keep getting an error saying I can't access the string because it is a private member. Is there a way to access the string without having to pass it through the function wordBeginsAt?
As you can see I am trying to re-crate the output from the first loop in my second loop, however it is with little success. The second loop's first run re-crates the last output of the first loop and if I use FileStructPointer++ or -- the output goes broke.
See attached for how it looks in the console window.
i need to return a struct pointer dynamically allocated inside a function call void function() which is done using 'out parameters' in following code
struct my_struct { int x; } void my_function( my_struct** result ) { my_struct* x = new my_struct{ 10 }; //... *result = x; }
Now i have a doubt, so if i want to print the return value from struct pointer, should i need to print it in the void function() or in the caller the function...
why I cannot get correct value for the third element in my struct?In the second file where I'm reading from memory I allocate some space. Is this incorrect in some way? I'm running this on a Linux machine.
keep getting "deferencing pointer to incomplete type" on the bold lines:
main: int main(int argc, char *argv[]) { printf("Please think of an animal. I will try to find out what it is by asking you some yes/no questions."); struct treenode *root = mkTreeNode("Is it a reptile? ", NULL, NULL); struct treenode *selectedNode = root; root->left = mkTreeNode("Does it have legs?