618 questions
726
votes
35
answers
2.5m
views
Parse (split) a string in C++ using string delimiter (standard C++)
I am parsing a string in C++ using the following:
using namespace std;
string parsed,input="text to be parsed";
stringstream input_stringstream(input);
if (getline(input_stringstream,parsed,' '))
{
...
183
votes
3
answers
90k
views
How can I concatenate twice with the C preprocessor and expand a macro as in "arg ## _ ## MACRO"?
I am trying to write a program where the names of some functions are dependent on the value of a certain macro variable with a macro like this:
#define VARIABLE 3
#define NAME(fun) fun ## _ ## ...
132
votes
2
answers
79k
views
Creating C macro with ## and __LINE__ (token concatenation with positioning macro)
I want to create a C macro that creates a function with a name based
on the line number.
I thought I could do something like (the real function would have statements within the braces):
#define UNIQUE ...
54
votes
8
answers
30k
views
Using a string path to set nested array data [duplicate]
I have an unusual use-case I'm trying to code for. The goal is this: I want the customer to be able to provide a string, such as:
"cars.honda.civic = On"
Using this string, my code will set a value ...
138
votes
16
answers
440k
views
How does strtok() split the string into tokens in C?
Please explain to me the working of strtok() function. The manual says it breaks the string into tokens. I am unable to understand from the manual what it actually does.
I added watches on str and *...
569
votes
8
answers
448k
views
What is token-based authentication?
I want to understand what token-based authentication means. I searched the internet but couldn't find anything understandable.
17
votes
2
answers
25k
views
Nested strtok function problem in C [duplicate]
I have a string like this:
a;b;c;d;e
f;g;h;i;j
1;2;3;4;5
and i want to parse it element by element. I used nested strtok function but it just splits first line and makes null the token pointer. How ...
106
votes
9
answers
244k
views
Get refresh token google api
I can't get my refresh token with my code. I can only get my access token, token type etc.,
I have followed some tutorials like putting access_type=offline on my login URL:
echo "<a href='https://...
42
votes
7
answers
84k
views
Split a string into words by multiple delimiters [duplicate]
I have some text (meaningful text or arithmetical expression) and I want to split it into words.
If I had a single delimiter, I'd use:
std::stringstream stringStream(inputString);
std::string word;
...
176
votes
13
answers
168k
views
Do Google refresh tokens expire?
I have used the refresh token several times in just a short period for testing purposes, but I wonder whether Google refresh tokens ever expire? Can I use the same refresh token to get another access ...
93
votes
5
answers
90k
views
Generating cryptographically secure tokens
In order to generate a 32 character token for access to our API we currently use:
$token = md5(uniqid(mt_rand(), true));
I have read that this method is not cryptographically secure as it's based on ...
48
votes
12
answers
312k
views
Error: Uncaught SyntaxError: Unexpected token <
For some reason, I'm getting this error message:
Uncaught SyntaxError: Unexpected token <
For this line of code:
title: '<img src="/images/text/text_mario_planet_jukebox.png" id="...
345
votes
19
answers
765k
views
Sending the bearer token with axios
In my react app i am using axios to perform the REST api requests.
But it's unable to send the Authorization header with the request.
Here is my code:
tokenPayload() {
let config = {
headers: ...
177
votes
4
answers
202k
views
Authenticating socket io connections using JWT
How can I authenticate a socket.io connection? My application uses a login endpoint from another server (python) to get a token, how can I get use that token whenever a user opens a socket connection ...
242
votes
25
answers
145k
views
Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead [duplicate]
I was using a username password for pushing my code. It was working for several months, but suddenly I'm not able to do it and am getting this error:
Username for 'https://github.com': shreyas-jadhav
...