digitalmars.D.learn - not callable error
- bluphantom91 (44/44) Nov 03 2016 Hello,
- Paul Backus (3/12) Nov 03 2016 Since you're using the C library stdio functions, you should
- bluphantom91 (5/21) Nov 04 2016 ok I added that in, but now its giving me this:
- Nemanja Boric (6/29) Nov 04 2016 You're mixing Phobos' `File` object and C's FILE stream. You're
- lobo (8/31) Nov 04 2016 Try something like this:
- Anders S (6/20) Dec 16 2016 Hi, I having equal problems and it looks like you get the
Hello, I am trying to finish up a group project but I am running into a small problem. I keep getting an error about fgetc not being callable. The purpose of my program is to count the number of characters in a file. Any bit of help is appreciated! Here's my code: import std.stdio; import std.file; import std.string; void main() { FILE *file; char ch; int charCount,wordCount,input; //File file = File("test.txt","w"); //input=fscanf(file, "%ch",&ch); //file.writeln("hello"); //string s = file.readln(); file=fopen("test,txt","r"); while(!file.eof()) { /*string line = chomp(file.readln()); wordCount++; writeln(wordCount);*/ ch = getc(file); charCount++; } file.close(); }
Nov 03 2016
On Friday, 4 November 2016 at 02:28:17 UTC, bluphantom91 wrote:Hello, I am trying to finish up a group project but I am running into a small problem. I keep getting an error about fgetc not being callable. The purpose of my program is to count the number of characters in a file. Any bit of help is appreciated! Here's my code: import std.stdio; import std.file; import std.string;Since you're using the C library stdio functions, you should import core.stdc.stdio
Nov 03 2016
On Friday, 4 November 2016 at 02:59:49 UTC, Paul Backus wrote:On Friday, 4 November 2016 at 02:28:17 UTC, bluphantom91 wrote:ok I added that in, but now its giving me this: function core.stdc.stdio.getc (shared(_IO_FILE)* stream) is not callable using argument types (File) Am I just using getc the wrong way?Hello, I am trying to finish up a group project but I am running into a small problem. I keep getting an error about fgetc not being callable. The purpose of my program is to count the number of characters in a file. Any bit of help is appreciated! Here's my code: import std.stdio; import std.file; import std.string;Since you're using the C library stdio functions, you should import core.stdc.stdio
Nov 04 2016
On Friday, 4 November 2016 at 14:37:04 UTC, bluphantom91 wrote:On Friday, 4 November 2016 at 02:59:49 UTC, Paul Backus wrote:You're mixing Phobos' `File` object and C's FILE stream. You're passing the `File` to getc which expects FILE. Also, if there's no specific reason, you should prefer the Phobos' file (which doesn't work with getc from C, as it would require obtaining the C stream from Phobos object, which would not be the best idea).On Friday, 4 November 2016 at 02:28:17 UTC, bluphantom91 wrote:ok I added that in, but now its giving me this: function core.stdc.stdio.getc (shared(_IO_FILE)* stream) is not callable using argument types (File) Am I just using getc the wrong way?Hello, I am trying to finish up a group project but I am running into a small problem. I keep getting an error about fgetc not being callable. The purpose of my program is to count the number of characters in a file. Any bit of help is appreciated! Here's my code: import std.stdio; import std.file; import std.string;Since you're using the C library stdio functions, you should import core.stdc.stdio
Nov 04 2016
On Friday, 4 November 2016 at 14:37:04 UTC, bluphantom91 wrote:On Friday, 4 November 2016 at 02:59:49 UTC, Paul Backus wrote:Try something like this: ... ch = getc(file.getFP); ... https://dlang.org/phobos/std_stdio.html#.File.getFP bye, loboOn Friday, 4 November 2016 at 02:28:17 UTC, bluphantom91 wrote:ok I added that in, but now its giving me this: function core.stdc.stdio.getc (shared(_IO_FILE)* stream) is not callable using argument types (File) Am I just using getc the wrong way?Hello, I am trying to finish up a group project but I am running into a small problem. I keep getting an error about fgetc not being callable. The purpose of my program is to count the number of characters in a file. Any bit of help is appreciated! Here's my code: import std.stdio; import std.file; import std.string;Since you're using the C library stdio functions, you should import core.stdc.stdio
Nov 04 2016
On Friday, 4 November 2016 at 23:26:40 UTC, lobo wrote:On Friday, 4 November 2016 at 14:37:04 UTC, bluphantom91 wrote:Hi, I having equal problems and it looks like you get the solution. so is it posible to get the full code listing from import .... to the counting that is working? Just as a conclusive answer for others aswell to read. /andersOn Friday, 4 November 2016 at 02:59:49 UTC, Paul Backus wrote:Try something like this: ... ch = getc(file.getFP); ... https://dlang.org/phobos/std_stdio.html#.File.getFP bye, loboOn Friday, 4 November 2016 at 02:28:17 UTC, bluphantom91 wrote:Am I just using getc the wrong way?Hello,....
Dec 16 2016