Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:50:06+00:00 2026-06-16T19:50:06+00:00

I am using strtok() the string tokenizer input is like say a,b,c,d|12,34,56,78 I am

  • 0

I am using strtok() the string tokenizer

input is like say

"a,b,c,d|12,34,56,78"

I am doing

      char * cols;
      char * vals;
      $char col_val_temp[1024] = {0};
      $char col_val[1024] = {0};

      cols = strtok(input,"|");
      vals = strtok('\0',"|");
      // now vals will have "12,34,56,78"
      strcpy(col_val_temp,vals);
      strcpy(col_val,col_val_temp);

and in the later part of code I am again using strtok on vals but, I see in debugger that suddenly out of no where the value of col_val becomes null while there is data present in col_val_temp. I have not done any operation on col_val string, so I don’t understand why the data in there is getting lost.

Can someone please explain why I am getting this behavior and how to overcome this.
I am stuck because of this.

Thanks !!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:50:07+00:00Added an answer on June 16, 2026 at 7:50 pm

    There is (at least) one buffer overrun problem in your code.

    You do a strcpy to seqno. seqno is declared only one character long, so the string terminator will probably overwrite the pointer value of cols.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function using strtok like this void f1(char *name) { ... char
strtok wont work correctly when using char *str as the first parameter (not the
I am using a simple program to tokenize a string using strtok function. Here
The input is string[] like below. "CSE111: CSE110 MATH101" "CSE110:" I need to order
I'm using strtok to split a string into tokens. Does anyone know any function
I am using strtok to extract 2 words from a string names[result]. I want
Is there anything I should know about using strtok on a malloced string? In
I am trying to copy a string into another char pointer variable using strcpy
I have a string which has been sent using udp. Now I want to
Is there a way in C to split a string (using strtok or any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.