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

  • Home
  • SEARCH
  • 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 4581052
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:52:12+00:00 2026-05-21T20:52:12+00:00

I am working on a university assignment and I’ve been wracking my head around

  • 0

I am working on a university assignment and I’ve been wracking my head around a weird problem where my program calls strtok and never returns.

My code looks like:

int loadMenuDataIn(GJCType* menu, char *data)
{
   char *lineTokenPtr;
   int i;

   lineTokenPtr = strtok(data, "\n"); 
   while (lineTokenPtr != NULL) { 

   /* ... */

   }

}

I’ve looked up a bunch of sites on the web, but I cant see anything wrong with the way that I am using strtok and I cant determine why it would my code would get stuck on the line lineTokenPtr = strtok(data, "\n");

Can anyone help me shed some light on this?

(Using OSX and Xcode if it makes any difference)

  • 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-05-21T20:52:13+00:00Added an answer on May 21, 2026 at 8:52 pm

    have you checked the contents of the argument? is it \0 terminated?

    the argument that you pass, is it writeable memory? strtok writes to the buffer that it gets as first argument when it tokenizes the string.

    IOW if you write

    char* mystring = "hello\n";
    
    strtok(mystring,"\n"); // you get problems
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a university assignment, based largely around IPC and shared memory.
so I've been working on a project on the university lab computers, and I
I'm working on a game for a university assignment and I want to create
I'm working on a university assignment to improve a game engine. The code we've
I am a university student. I have been working a lot with Android lately
I am working on a university project and i have the following problem i
I'm working on a university assignment. I am trying to write a linked-list sort
I am currently working on a university project, using HTML5. I have been writing
While I was working on an University project, I used a project-internal profiler made
I'm working on a project whereby the University has full control over the source

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.