Skip to main content

All Questions

Tagged with
2 votes
4 answers
113 views

Is there a way to compare multiple strings in C? [ I input them through fgets() ]

int Distance() { char from[40], to[40]; double val; double result; printf("Enter what you want to convert from: "); fflush(stdin); fgets(from, 40, stdin); ...
sumiicode.exe's user avatar
0 votes
2 answers
499 views

How do I use multiple fgets without them interfering with each other?

Here's the basic skeleton of my code: int getSentence(SearchResults* input){ printf("Enter sentence:"); fgets(input->sentence, 100, stdin); printf("Enter message ID:&...
C-J-B's user avatar
  • 55
1 vote
2 answers
55 views

Java Stdin Cannot convert from String[] to String, but inputs are String?

I am doing a programming assignment that takes all of its input from stdin. The first input is an int n to tell you how many strings will follow, and the next n inputs are strings of varying lengths. ...
Gynzie's user avatar
  • 11
0 votes
5 answers
126 views

Substite newlines with a string with awk

I need to parse stdin in the following way: (1) all newlines characters must be substituted with \n (a literal \ followed by n) (2) nothing else should be performed except the previous I chose awk to ...
robertspierre's user avatar
0 votes
0 answers
45 views

Java - Unicode input in cmd.exe doesn't match from other languages (like Node)

While reading input from the console via cmd.exe using Java, I noticed that if I input a string with Chinese characters (你好), it would always return a 65 (Char code for ?) in place of the character. ...
rfl890's user avatar
  • 92
1 vote
0 answers
213 views

Is there a more efficient way of reading from stdin and tokenizing than allocating a large buffer and using string_view?

I'm reading a file from stdin and just need to run through it as fast as possible and do some processing on each of the delimited tokens. #include <iostream> #include <array> #include <...
ajoseps's user avatar
  • 2,041
-1 votes
2 answers
264 views

reading string from a file via stdin in c11

So I have a .txt file that I want to read via stdin in c11 program using scanf(). The file is essentially many lines made of one single string. example: hello how are you How can I know when the file ...
Proth's user avatar
  • 39
1 vote
1 answer
405 views

Taking string input of exact size from stdin in C

I've written a function that requires the user to enter a string of size 13, 15, or 16. The function keeps looping till the required length is entered. I am new to C. This function is part of one of ...
kbl's user avatar
  • 169
1 vote
0 answers
95 views

How to split multiline stdin input in r?

I am working in R and am supposed to split the stdin inputs using space and newline characters. However, when I take the input as a string from stdin using the following code: f <- file("stdin&...
Naman Bansal's user avatar
-1 votes
1 answer
708 views

Convert string to double in C

I have to read from a txt file these lines: 1 334.5909245845 161.7809319139 2 397.6446634067 262.8165330708 3 503.8741827107 172.8741151168 4 444.0479403502 384.6491809647 5 311.6137146746 2....
Ele975's user avatar
  • 362
1 vote
0 answers
463 views

PowerShell string from stdin

I'm busy with writing a script to process log files, that contain multi-line events. I'm using this line to split up the file to individual events: $Messages = ((Get-Content $File -Raw) -split '(?m)(?=...
Radir's user avatar
  • 11
0 votes
1 answer
21 views

Separate even and odd index of strings and print them respectively - Problem with last char print

I know there is 2 other discussion on this topic but I can't find the response to my single problem. When I print the last character of my even (or odd) index string, I looks like weird ones. I think ...
Mickael Evrard's user avatar
3 votes
1 answer
722 views

std::string gets truncated after 4095 characters froms std::cin

My programs needs to read up to 50k character long strings from stdin. The code is as follows: #include <iostream> #include <string> std::string A; int main(){ std::cin >> A; ...
Jan's user avatar
  • 51
0 votes
1 answer
304 views

c - fgets never return \0 and cause a infinite loop

I tried to make a while loop reading some strings from stdin but it never ends fgets(string,stringlenght,stdin); while (string[0] != '\0') { ///some stuff here fgets(string,stringlenght,...
devastatedbuga's user avatar
0 votes
1 answer
94 views

How to split a char array into two diferent types in c?

So, I need to use the stdin to read a file that has two columns, the first one is a char, the second is an integer. The input file is something like this: i 10 i 20 i 30 i 40 i 50 i 45 r 48 My code ...
Leonardo Camargo's user avatar

15 30 50 per page
1
2 3 4 5
7