Hi
I'm sorry if this seems like a bit of a silly question but i'm very new to c programming and I'm having a few real problems doing this.
The way my code works is that there is a main method which calls a series of methods to obtain data from a socket and validate the data.
The issue I'm having is when I come to pass back the validated data to main.
I have a a 57 character field 'message' that I want to return, however I can't seem to do this so I thought I'd try returning '&message' instead.
I'm getting a warning that 'function returns an address of a local variable' so I'm assuming that this will be no good as the memory address can only be used by the method and can't be passed back.
I've had a search about and it talks about using structs for this but I don't have any experience of using them at all.
Does anyone havea recommendation for doing this?
Could I pass the memory address from main down into the later methods and then write to that memory address within one of the called methods?
Thanks in advance
Adam
I'm sorry if this seems like a bit of a silly question but i'm very new to c programming and I'm having a few real problems doing this.
The way my code works is that there is a main method which calls a series of methods to obtain data from a socket and validate the data.
The issue I'm having is when I come to pass back the validated data to main.
I have a a 57 character field 'message' that I want to return, however I can't seem to do this so I thought I'd try returning '&message' instead.
I'm getting a warning that 'function returns an address of a local variable' so I'm assuming that this will be no good as the memory address can only be used by the method and can't be passed back.
I've had a search about and it talks about using structs for this but I don't have any experience of using them at all.
Does anyone havea recommendation for doing this?
Could I pass the memory address from main down into the later methods and then write to that memory address within one of the called methods?
Thanks in advance
Adam
Comment